Unit 2 Microprocessor
Unit 2 Microprocessor
The 8085 microprocessor is an 8-bit microprocessor that was developed by Intel in the mid-1970s. It was
widely used in the early days of personal computing and was a popular choice for hobbyists and enthusiasts
due to its simplicity and ease of use. The architecture of the 8085 microprocessor consists of several key
components, including the accumulator, registers, program counter, stack pointer, instruction register, flags
register, data bus, address bus, and control bus.
The accumulator is an 8-bit register that is used to store arithmetic and logical results. It is the most commonly
used register in the 8085 microprocessor and is used to perform arithmetic and logical operations such as
addition, subtraction, and bitwise operations.
1.
The 8085 microprocessor has six general-purpose registers, including B, C, D, E, H, and L, which can be
combined to form 16-bit register pairs. The B and C registers can be combined to form the BC register pair, the
D and E registers can be combined to form the DE register pair, and the H and L registers can be combined to
form the HL register pair. These register pairs are commonly used to store memory addresses and other data.
The program counter is a 16-bit register that contains the memory address of the next instruction to be
executed. The program counter is incremented after each instruction is executed, which allows the
microprocessor to execute instructions in sequence.
The stack pointer is a 16-bit register that is used to manage the stack. The stack is a section of memory that is
used to store data temporarily, such as subroutine addresses and other data. The stack pointer is used to keep
track of the top of the stack.
The instruction register is an 8-bit register that contains the current instruction being executed. The instruction
register is used by the microprocessor to decode and execute instructions.
2.
The flags register is an 8-bit register that contains status flags that indicate the result of an arithmetic or logical
operation. These flags include the carry flag, zero flag, sign flag, and parity flag. The carry flag is set when an
arithmetic operation generates a carry, the zero flag is set when the result of an arithmetic or logical operation is
zero, the sign flag is set when the result of an arithmetic or logical operation is negative, and the parity flag is
set when the result of an arithmetic or logical operation has an even number of 1 bits.
3.
The data bus is an 8-bit bus that is used to transfer data between the microprocessor and memory or other
devices. The data bus is bidirectional, which means that it can be used to read data from memory or write data
to memory.
The address bus is a 16-bit bus that is used to address memory and other devices. The address bus is used to
select the memory location or device that the microprocessor wants to access.
4.
The control bus is a set of signals that controls the operations of the microprocessor, including the read and
write operations. The control bus includes signals such as the read signal, write signal, interrupt signal, and
reset signal. The read signal is used to read data from memory or other devices, the write signal is used to write
data to memory or other devices, the interrupt signal is used to signal the microprocessor that an interrupt has
occurred, and the reset signal is used to reset the microprocessor to its initial state.
8085 is an 8-bit, general-purpose microprocessor. It consists of the following functional units:
Arithmetic and Logic Unit (ALU) :
It is used to perform mathematical operations like addition, multiplication, subtraction, division, decrement,
increment, etc. Different operations are carried out in ALU: Logical operations, Bit-Shifting Operations, and
Arithmetic Operations.
Flag Register:
It is an 8-bit register that stores either 0 or 1 depending upon which value is stored in the accumulator. Flag
Register contains 8-bit out of which 5-bits are important and the rest of 3-bits are “don’t Care conditions”. The
flag register is a dynamic register because after each operation to check whether the result is zero, positive or
negative, whether there is any overflow occurred or not, or for comparison of two 8-bit numbers carry flag is
checked. So for numerous operations to check the contents of the accumulator and from that contents if we
want to check the behavior of given result then we can use Flag register to verify and check. So we can say that
the flag register is a status register and it is used to check the status of the current operation which is being
carried out by ALU.
Different Fields of Flag Register:
1. Carry Flag
2. Parity Flag
3. Auxiliary Carry Flag
4. Zero Flag
5. Sign Flag
Accumulator:
Accumulator is used to perform I/O, arithmetic, and logical operations. It is connected to ALU and the internal
data bus. The accumulator is the heart of the microprocessor because for all arithmetic operations
Accumulator’s 8-bit pin will always there connected with ALU and in most-off times all the operations carried
by different instructions will be stored in the accumulator after operation performance.
Program Counter :
Program Counter holds the address value of the memory to the next instruction that is to be executed. It is a
16-bit register.
Stack Pointer :
It works like a stack. In stack, the content of the register is stored that is later used in the program. It is a 16-bit
special register. The stack pointer is part of memory but it is part of Stack operations, unlike random memory
access. Stack pointer works in a continuous and contiguous part of the memory. whereas Program Counter(PC)
works in random memory locations. This pointer is very useful in stack-related operations like PUSH, POP, and
nested CALL requests initiated by Microprocessor. It reserves the address of the most recent stack entry.
Temporary Register:
It is an 8-bit register that holds data values during arithmetic and logical operations.
Interrupt control:
Whenever a microprocessor is executing the main program and if suddenly an interrupt occurs, the
microprocessor shifts the control from the main program to process the incoming request. After the request is
completed, the control goes back to the main program. There are 5 interrupt signals in 8085 microprocessors:
INTR, TRAP, RST 7.5, RST 6.5, and RST 5.5.
Priorities of Interrupts: TRAP > RST 7.5 > RST 6.5 > RST 5.5 > INTR
● VCC – Pin number 40 denotes VCC, and an external power supply of + 5 V is provided at this pin.
● VSS – Its pin number is 20. This pin shows the grounded connection of the microprocessor.
● X1 and X2 – These are represented by pin number 1 and 2 respectively in the pin configuration.
These 2 pins are connected with a crystal or LC network to maintain the internal frequency of the
clock generator.
● CLK (OUT) – It is the 37th pin of the 8085 IC and acts as the system clock that keeps the record of
time duration required by each operation to get completed.
2.Address Bus – This category contains 8 pins.
The address bus has 16 lines i.e.; it can carry 16 bits at a time. However, out of 16, 8 are multiplexed with the
data bus and the leftover 8 are separately shown by pin number 21 to 28 in the pin configuration.
These are used to carry the address of data and instruction from the processor to the memory location and is
unidirectional in nature. These are denoted by A8 to A15 that represents the 8 MSB of the memory location or
input-output address.
3.Data Bus with multiplexed address bus – This category also contains 8 pins.
The size of the data bus of the 8085 microprocessor is 8 bits. However, to reduce the number of bus lines these
8-bit data bus lines are multiplexed with the 8-bit address bus.
These are shown by pin number 12 to 19. The address bus is denoted by A whereas the data bus is denoted by
D. The pin configuration denotes the lower order multiplexed address and data bus bits from AD0 to AD7.
We have already discussed that the address bus contains the address of the desired memory location from
where the data or instruction is to be fetched. While the data bus contains the data or instruction that is needed to
be fetched from the memory.
4.Serial I/O ports :
It has basically 2 pins.
● SID – SID denotes serial input data pin and its pin is numbered as 5. With this pin, data is serially
fed to the processor directly through the input devices.
● SOD – SOD denotes serial output data pin and its pin number is 4, in the pin configuration of
8085. Once the data is processed in the microprocessor then this pin represents bit by bit results at
the output devices.
5.Control and status signals :
Basically, 6 pins of the pin configuration are used by control and status signals.
● ALE – ALE is an acronym for address latch enable and is pin number 30 in the configuration. We
know that 8 lower order bits of the 16-bit address bus are multiplexed with the 8-bit data bus.
This pin gets enabled at the time when the address is present at the multiplexed address and data bus.
Otherwise, it gets disabled showing the absence of an address on the bus.
● RD – This pin is numbered 32 in the configuration and a low signal in this pin shows the read
operation either from I/O devices or from the memory unit. Thereby indicating that the data bus is
now in a state or position to accept the data from the memory or I/O devices.
● WR – It is the 31st pin in the pin diagram and a low signal in this pin represents the write operation
at the memory or I/O devices. This indicates that the data present in the data bus is to be written
into the desired memory address or I/O device by the processor.
● IO/M – It is pin number 34 and indicates the selection of a memory address or input-output device.
This shows whether the read/write operation is to be carried out at the memory location or at the
I/O device.
The low signal at this pin shows that operation is performing over memory location. As against, a high signal at
this pin represents the operation at I/O device.
● S0 and S1 – The pins S0 and S1 represent the status signal at pin number 29 and 33
respectively. These signals show the type of recent operation of the microprocessor. The table
below represents the status of the data bus under different conditions:
Machine Cycle in 8085 Microprocessor:The seven Machine Cycle in 8085 Microprocessor are :
1. Opcode Fetch Cycle
2. Memory Read
3. Memory Write
4. I/O Read
5. I/O Write
6. Interrupt Acknowledge
7. Bus Idle
1. Opcode Fetch Cycle:The first Machine Cycle of 8085 Microprocessor of every instruction is opcode fetch
cycle in which the 8085 finds the nature of the instruction to be executed. In this Machine Cycle in 8085,
processor places the contents of the Program Counter on the address lines, and through the read process, reads
the opcode of the instruction. Fig. 1.15 (a) shows flow of data (opcode) from memory to the microprocessor and
Fig. 1.15 (b) shows the timing diagram for Opcode Fetch Machine Cycle 8085. The length of this cycle is not
fixed. It varies from 4T states to 6T states as per the instruction. The following section describes the opcode fetch
cycle in step by step manner.
Step 1 : (State T1): In T1 state, the 8085 places the contents of program counter on the address bus. The
high-order byte of the PC is placed on the A8 – A15 lines. The low-order byte of the PC is placed on the AD0 –
AD7 lines which stays on only during T1. Thus microprocessor activates ALE (Address Latch Enable) which is
used to latch the low-order byte of the address in external latch before it disappears.In T1, 8085 also sends
status signals IO/M, S1, and S0. IO/M specifies whether it is a memory or I/O operation, S1 status specifies
whether it is read/write operation; S1 and S0 together indicates read, write, opcode fetch, machine cycle
operation, or whether it is in HALT state. In opcode fetch machine cycle status signals are : IO/M = 0, S1 = 1, S0
= 1.
Step 2 : (State T2) In T2, low-order address disappears from the AD0 – AD7 lines. (However A0 – A7 remain
available as they were latched during T1). In T2, 8085 sends RD signal low to enable the addressed memory
location. The memory device then places the contents of addressed memory location on the data bus (AD0 –
AD7).
Step 3 : (State T3) During T3, 8085 loads the data from the data bus in its Instruction Register and raises RD to
high which disables the memory device.
Step 4 : (State T4) In T4, microprocessor decodes the opcode, and on the basis of the instruction received, it
decides whether to enter state T5 or to enter state T1 of the next Machine Cycle of 8085 Microprocessor. One
byte instructions those operate on eight bit data (8 bit operand) are executed in T4.
For example : MOV A, B, ANA D, ADD B, INR L, DCR C, RAL and many more.
Note : For one byte instructions which operate on eight bit data, data is always available in the internal memory
of 8085 i.e. registers.
Step 5 : (State T5 and T6) State T5 and T6, when entered, are used for internal microprocessor operations
required by the instruction. During T5 and T6 , 8085 performs stack write, internal 16 bit; and conditional return
operations depending upon the type of instruction. One byte instructions those operate on sixteen bit data (16 bit
operand) are executed in T5 and T6. For example DCX H, PCHL, SPHL, INX H, etc.
Step 1 : (State T1) In T1 state, the 8085 places the address on the address lines from stack pointer or general
purpose register pair and activates ALE signal in order to latch low-order byte of address. During T1, 8085 sends
status signals :
IO/M = 0, S1 = 0 and S0 = 1 for memory write machine cycle.
Step 2 : (State T2) In T2, 8085 places data on the data bus and sends WR signal low for writing into the
addressed memory location.
Step 3 : (State T3) During T3, WR signal goes high, which disables the memory device and terminates the write
operation.
4, 5. I/O Read and I/O Write cycles:
The I/O read and I/O write machine cycles are similar to the memory read and memory write machine cycles,
respectively, except that the 10/M signal is high for I/O read and I/O write machine cycles. High IO/M signal
indicates that it is an I/O operation. Fig. 1.18 (b) and Fig. 1.19 (b) show the timing diagrams for I/O read and I/O
write cycles, respectively.
6. Interrupt Acknowledge Cycle:
In response to INTR signal, 8085 executes interrupt acknowledge machine cycle to read an instruction from the
external device. Theoretically, the external device can place any instruction on the data bus in response to INTA.
However, only RST and CALL, save the PC contents (return address) before transferring control to the interrupt
service routine. The next sections explain Interrupt Acknowledge Cycle of 8085 for RST and CALL instructions.
Interrupt Acknowledge Cycle for RST instruction:
The number of machine cycles required to fetch complete instruction depends on the instruction type :
1. One byte 2. Two byte or 3. Three byte
One byte instruction doesn’t require any additional machine cycle. Two byte instruction requires one additional
memory read machine cycle, whereas three byte instruction requires two additional memory read machine
cycles.
The number of Machine Cycle in 8085 required to execute the instruction depends on the particular instruction.
The total number of machine cycles required varies from one to five. It is possible that memory read and memory
write machine cycles occur more than once in a single instruction cycle. The following examples illustrate the
timing diagrams and machine cycles used for few 8085 instructions.
Concept of Wait States in 8085:
In some applications, speed of memory system and I/O system are not compatible with the microprocessor’s
timings. This means that they take longer time to read/write data. in such situations, the microprocessor has to
confirm whether a peripheral is ready to transfer data or not. If READY pin is high, the peripheral is ready
otherwise 8085 enters wait state.
Fig. 1.24 shows the timing diagram for memory read machine cycle with and without wait state.
Concept of Wait States in 8085 continue to be inserted as long as READY is low. After the wait state, 8085
continues with T3 of the machine cycle. During a wait state the contents of the address bus, the data bus, and
the control bus are all held constant.
The wait state then gives an addressed memory or I/O port an extra clock cycle time to output valid data on the
data bus. This feature allows to use cheaper memory or I/O devices that have longer access times.
6.Interrupts and Externally generated signals:
Interrupts are the signals that are generated to break the sequence of an ongoing operation. When an interrupt
signal is generated then CPU immediately stops its recent task under operation and switches to some other
program known as interrupt service routine (ISR).
However, after handling ISR, the CPU gets back to its main program for execution.
In the pin configuration, 5 types of interrupts are shown by 5 different pins from pin number 6 to 10. These pins
are used to manage the interrupt.
Basically, there exist 2 types of interrupts:
Maskable Interrupt and Non- maskable interrupt
Out of the 5 major interrupts 4 are the maskable interrupts. These are INTR, RST5.5, RST6.5, RST7.5 and are
easily manageable interrupts.
However, TRAP is a non-maskable interrupt and holds the topmost priority among all interrupts in the 8085
microprocessor.
● RESET IN – It is pin number 36 in the pin diagram. An active low signal at this pin resets the PC of
the microprocessor to 0. Or we can say, after resetting the PC holds its initial memory address.
● RESET OUT – It is the 3rd pin in the pin diagram. This pin generates a signal to provide
information about the resetting of the microprocessor. Also, we can say that once a processor is
reset then all the connected devices must also be reset.
So, enabling this signal shows the resetting of the interconnected devices.
● INTA: It is the 11th pin of the 8085 pin configuration. A signal at this pin acknowledges the
generated interrupt.
7.Direct Memory Access (DMA) :
We are aware of the fact that memory and I/O devices are connected with each other by the microprocessor. So,
the intermediator i.e., CPU manages the data transfer between the input-output device and memory.
However, when data in a large amount is to be transferred between I/O devices and memory the CPU gets
disabled by tri-stating its buses. And this transfer is manageable by external control circuits. The DMA has 2 pins.
● HOLD – This signal is generated at pin number 39. This pin generates a signal to notify the
processor that more than one request is present to access the data and address bus.
When this signal gets enabled, the CPU frees the bus after completion of the recent operation. Once the hold
signal gets disabled, the processor can access the bus again.
● HLDA -This signal is generated at pin number 38. This signal is enabled at the time when the
processor gets HOLD signal and it releases HLDA i.e., hold acknowledge signal. In order to show
that the multiple requests are kept on hold and will be considered once the bus gets free after the
recent operation.
After the disabling of hold request, the HLDA signal becomes low.
● READY -This is the 35th numbered pin in the pin diagram that maintains synchronization between
the processor and peripherals, memory. It is clear that a microprocessor has a much faster
response than peripherals and memory.
So, this pin is enabled when the processor as well as the peripherals and memory both become ready to begin
the next operation.
In the case when the READY pin is disabled, then the microprocessor is in the WAIT state.
Instruction Format of 8085:
Each Instruction Format of 8085 and Data Format of 8085 microprocessor has specific information fields. These
information fields of instructions are called elements of instruction. These are :
● Operation code : The operation code field in the instruction specifies the operation to be
performed. The operation is specified by binary code, hence the name operation code or
simply opcode. For example, for 8085 processor operation code for ADD B instruction is 80H.
● Source / destination operand : The source/destination operand field directly specifies the
source/destination operand for the instruction. In the Instruction Format of 8085, the
instruction MOV A,B has B register contents as a source operand and A register contents as a
destination operand because this instruction copies the contents of register B to register A.
● Source operand address : We know that the operation specified by the instruction may require
one or more operands. The source operand may be in the 8085 register or in the memory.
Many times the Instruction Format of 8085 specifies the address of the source operand so
that operand(s) can be accessed and operated by the 8085 according to the instruction.
In 8085, the source operand address for instruction ADD M is given by HL register pair.
● Destination operand address : The operation executed by the 8085 may produce result. Most
of the times the result is stored in one of the operand. Such operand is known as destination
operand. The Instruction and Data Format of 8085 which produce result specifies the
destination operand address. In 8085, the destination operand address for instruction INR M
is given by HL register pair because INR M instruction increments the contents of memory
location specified by HL register pair and stores the result in the same memory location.
● Next instruction address : The next instruction address tells the 8085 from where to fetch the
next instruction after completion of execution of current instruction. For BRANCH instructions
the address of the next instruction is specified within the instruction. However, for other
instructions, the next instruction to be fetched immediately follows the current instruction. For
example, in 8085, instruction after INR B follows it. The instruction JMP 2000H specifies the
next instruction address as 2000H.
Instruction Formats:
The Instruction Format of 8085 set consists of one, two and three byte instructions. The first byte is always the
opcode; in two-byte instructions the second byte is usually data; in three byte instructions the last two bytes
present address or 16-bit data.
1. One byte instruction :
For Example : MOV A, B whose opcode is 78H which is one byte. This Instruction and Data Format of 8085 copies
the contents of B register in A register.
2. Two byte instruction :
For Example : MVI B, 02H. The opcode for this instruction is 06H and is always followed by a byte data (02H in
this case). This instruction is a two byte instruction which copies immediate data into B register.
3. Three byte instruction :
For Example : JMP 6200H. The opcode for this instruction is C3H and is always followed by 16 bit address
(6200H in this case). This instruction is a three byte instruction which loads 16 bit address into program counter.
Opcode Format of 8085:
The 8085A microprocessor has 8-bit opcodes. The opcode is unique for each Instruction and Data Format of
8085 and contains the information about operation, register to be used, memory to be used etc. The 8085A
identifies all operations, registers and flags with a specific code. For example, all internal registers are identified
as shown in the Tables 2.1(a) and 2.2(b).
Similarly, there are different codes for each opera are identified as follows :
Note : DDD defines the destination register, SSS defines the source register and DD defines the register pair.
Data Format of 8085 Microprocessor:
The operand is an another name for data. It may appear in different forms :
● Addresses
● Numbers/Logical data and
● Characters
Addresses : The address is a 16-bit unsigned integer ,number used to refer a memory location.
Numbers/Data : The 8085 supports following numeric data types.
● Signed Integer : A signed integer number is either a positive number or a negative number. In
8085, 8-bits are assigned for signed integer, in which most significant bit is used for sign and
remaining seven bits are used for Sign bit 0 indicates positive number whereas sign bit 1
indicates negative number.
● Unsigned Integer : The 8085 microprocessor supports 8-bit unsigned integer.
● BCD : The term BCD number stands for binary coded decimal number. It uses ten digits from
0 through 9. The 8-bit register of 8085 can store two digit BCD
Characters : The 8085 uses ASCII code to represent characters. It is a 7-bit alphanumeric code that represents
decimal numbers, English alphabets, and other special characters.
Example: MOV AL, 35H (move the data 35H into AL register)
● Register mode: In register addressing the operand is placed in one of 8 bit or 16 bit general
purpose registers. The data is in the register that is specified by the instruction.
Here one register reference is required to access the data.
2. Specific data byte to register or a memory location Data Byte -> Register B
4. Between the I/O device and the accumulator Input Device -> Register A
5. Between a register pair and the stack Register Pair data -> Stack Location
13. XCHG
Now, we will see each instruction which we have to describe above table in detail.
MOV Rd, Rs
Operation Rd = Rs
T-States 4
Description This instruction copies data from the source register Rd to the destination register Rs.
The source register Rd and destination register Rs can be any general-purpose register like A,
B, C, D, E, H, or L.
The contents of the source register remain unchanged.
Example This instruction will copy the contents of register C to register B. The contents of register C
MOV C, M remain unchanged.
Example MOV B, C
Suppose B = 20H, C = 10H, and the instruction MOV B, C is executed. After the execution B
10H and C= 10H.
Mnemonics MOV R, M
Operation R = M or R = (HL)
T-States 4+3=7
Note:
1. Whenever the term M comes in an instruction, it is a memory pointer. The address will be given
by the HL register pair.
2. Brackets around HL specify that the contents are used as an address. Henceforth the brackets
will be used to specify the contents used ad address.
MOV M, R
Mnemonics MOV M, R
Operation M = R or (HL) = R
T-States 4+3=7
MVI R, Data
Operation R = data
T-States 4+3=7
Description This instruction moves the 8-bit immediate data to the specified register.
The data is specified within the instruction.
It is a two-byte instruction, so the first byte of instruction will be OPCODE, and the second
byte will be 8-bit data.
The register R can be any general-purpose register like A, B, C, D, E, H, or L.
Example This instruction will load the immediate data 07H in register D.
MVI D, 07H Let the contents of register D = 10H. Then after execution of instruction MVI D, 07H the
content of register D will be changed from 10H to 07H.
MVI M, data
T-States 4 + 3 + 3 = 10
T-States 4 + 3 + 3 = 10
Description This instruction will load the register pair with 16-bit data.
This instruction loads 16-bit data specified within the instruction to the specific register pair
or stack pointer.
In the instruction, only high order register is specified for the register pair. I.e if the HL pair
is to be loaded only the H register will be specified in the instruction.
The register pair Rp can be BC, DE, HL register pairs, or the stack pointer SP.
Example Load HL pair with 2030H. 20H will be loaded in the H register and 30H in the L register.
LXI H, 2030H The instruction will load stack pointer SP with 7FFFH.
LXI SP, 7FFFH
LDA Address
Operation A = (address)
T-States 4 + 3 + 3 + 3 = 13
Example This instruction will load the accumulator with the contents of memory location 5820H.
LDA 5820H Let initially A = F0H, contents of memory location 5820H = 15H.
Then after the execution of instruction LDA 5820H, the accumulator will be loaded with 15H.
The content of the accumulator will change from F0H to 15H.
Operation (address) = A
Example This instruction will store the contents of the accumulator at location 5820H.
LDA 5820H
Operation L = (address)
H = (Address + 1)
T-States 4 + 3 + 3 + 3 + 3 = 16
Description Load HL pairs directly from memory.
This instruction loads the contents of the memory location to the H and L registers. The
address of memory is specified along with the instruction.
The contents of the memory location whose address is specified in the instruction are
transferred to the L register and the contents of the next memory location i.e. (address + 1)
to the H register.
This instruction is used to load the H and L registers from memory.
It is a 3-byte instruction. The first byte is the opcode, the second byte is the lower-order
address and the third byte is the higher-order address.
Mnemonics LDAX Rp
Operation A = (Rp)
T-States 4+3=7
Description Load accumulator indirectly by using a memory pointer.
This instruction copies the contents of the memory location to the accumulator.
The address of memory location is given by R, register pair specified along with the
instruction.
The register pair Rp can be BC or DE only.
The contents of the memory location remain unchanged.
Example This instruction will load the accumulator with the contents of the memory location whose
LDAX B address is given by the BC register pair.
Let A = 1F H, B = 20H, C = 25H, at memory location 2025 : 56H is stored.
Then after the execution of instruction LDAX B, the accumulator will be loaded with the
contents of memory location 2025 i.e. 56 H.
STAX Rp
Mnemonics STAX Rp
Operation (Rp) = A
T-States 4+3=7
XCHG
Mnemonics XCHG
T-States 4
Example Let H = 12H, L = 11H, D = 30H, E executed. 40H and the instruction XCHG is executed.
XCHG
ADD
■ This is 1-byte instructions.
ADD R
■ Adds the contents of register R to the contents of the
accumulator.
Add Immediately
■ This is 2-byte instructions.
ADI 8-bit
■ Adds the second byte to the contents of the
accumulator
Subtract
■ This is 1-byte instructions.
SUB R+
■ Subtract the contents of register R from the contents of
the accumulator.
Subtract Immediately
■ This is 2-byte instructions.
SUI 8-bit
■ Subtracts the byte from the contents of the
accumulator.
Increment
■ This is 1-byte instructions.
INR R*
■ Increases the contents of register R by 1
Caution: All flags except the CY are affected
Decrement
■ This is 1-byte instructions.
DCR R*
■ Decreases the contents of register R by 1
Caution: All flags except the CY are affected.
Introduction :
Logical instructions in the 8085 microprocessor are a set of instructions that perform logical operations on data
in registers and memory. Logical operations are operations that manipulate the bits of data without affecting
their numerical value. These operations include AND, OR, XOR, and NOT.
The logical instructions in the 8085 microprocessor include:
1. ANA – Logical AND: This instruction performs a logical AND operation between the accumulator
and a specified register or memory location, and stores the result in the accumulator. For example,
the instruction “ANA B” performs a logical AND operation between the contents of the
accumulator and the contents of the B register.
2. ORA – Logical OR: This instruction performs a logical OR operation between the accumulator and
a specified register or memory location, and stores the result in the accumulator. For example, the
instruction “ORA C” performs a logical OR operation between the contents of the accumulator and
the contents of the C register.
3. XRA – Logical XOR: This instruction performs a logical XOR operation between the accumulator
and a specified register or memory location, and stores the result in the accumulator. For example,
the instruction “XRA M” performs a logical XOR operation between the contents of the
accumulator and the contents of the memory location pointed to by the HL register.
4. CPL – Logical Complement: This instruction performs a logical complement operation on the
contents of the accumulator. This operation flips all the bits of the accumulator, effectively
reversing its value.
5. CMA – Complement Accumulator: This instruction performs a bitwise complement operation on
the contents of the accumulator. This operation flips all the bits of the accumulator, effectively
reversing its value.
Logical instructions are the instructions that perform basic logical operations such as AND, OR, etc. In the 8085
microprocessor, the destination operand is always the accumulator. Here logical operation works on a bitwise
level.
ORA R A = A OR R ORA B
2. Data masking: Logical instructions can be used to selectively mask or extract specific bits of data.
For example, the AND instruction can be used to mask off all but a specific set of bits, while the
OR instruction can be used to set specific bits to 1.
3. Data encryption: Logical instructions can be used to perform bitwise encryption of data. By
performing a logical XOR between the data and a secret key, the data can be encrypted in a
reversible way that can only be decrypted with the same key.
4. Decision-making: Logical instructions can be used to make decisions in programs. For example, the
AND instruction can be used to test if multiple conditions are true, while the OR instruction can be
used to test if at least one condition is true.
Following is the table showing the list of logical instructions: In the table,
R stands for register
M stands for memory
Mc stands for memory contents
Applications :
Data processing: The logical instructions in the 8085 microprocessor are used to manipulate and process data
stored in memory or registers. These instructions are used to perform various logical operations, such as AND,
OR, XOR, and complement, which are used to filter, mask, and manipulate data in various ways.
Control systems: The logical instructions are used in control systems to perform logical operations on sensor
data and other inputs. These operations are used to generate control signals that regulate the behavior of the
system.
Signal processing: The logical instructions in the 8085 microprocessor are used in digital signal processing
applications, such as audio and image processing. These instructions are used to perform various logical
operations on the digital signal data, such as masking, filtering, and thresholding.
Communication systems: The logical instructions are used in communication systems to perform logical
operations on data, such as error detection and correction, and encryption/decryption.
Gaming: The logical instructions are used in gaming applications to perform logical operations on game data,
such as collision detection, pathfinding.
Branching instructions
Branching instructions refer to the act of switching execution to a different instruction sequence as a result of
executing a branch instruction.
The three types of branching instructions are:
1. Jump Instructions – The jump instruction transfers the program sequence to the memory address given in the
operand based on the specified flag. Jump instructions are 2 types: Unconditional Jump Instructions and
Conditional Jump Instructions.
(a) Unconditional Jump Instructions: Transfers the program sequence to the described memory address.
(b) Conditional Jump Instructions: Transfers the program sequence to the described memory address only if
the condition in satisfied.
2. Call Instructions – The call instruction transfers the program sequence to the memory address given in the
operand. Before transferring, the address of the next instruction after CALL is pushed onto the stack. Call
instructions are 2 types: Unconditional Call Instructions and Conditional Call Instructions.
(a) Unconditional Call Instructions: It transfers the program sequence to the memory address given in the
operand.
(b) Conditional Call Instructions: Only if the condition is satisfied, the instructions executes.
3. Return Instructions – The return instruction transfers the program sequence from the subroutine to the
calling program. Return instructions are 2 types: Unconditional Jump Instructions and Conditional Jump
Instructions.
(a) Unconditional Return Instruction: The program sequence is transferred unconditionally from the subroutine
to the calling program.
(b) Conditional Return Instruction: The program sequence is transferred unconditionally from the subroutine to
the calling program only is the condition is satisfied.
Advantages:
Enables conditional execution: The branching instructions in the 8085 microprocessor allow for conditional
execution of code, which can help optimize program flow and improve overall efficiency.
Simplifies programming: The branching instructions in the 8085 microprocessor simplify programming by
providing a set of dedicated instructions for branching to different memory locations based on conditions.
Supports a wide range of operations: The branching instructions in the 8085 microprocessor support a wide
range of operations, including conditional branching, unconditional branching, and subroutine calls.
Allows for loop execution: The branching instructions in the 8085 microprocessor can be used to implement
loops by branching to a memory location that contains a loop instruction.
Disadvantages:
Limited branching range: The 8085 microprocessor has a limited branching range, which can restrict the
amount of memory that can be accessed. This can be a disadvantage for applications that require a large
number of branching instructions.
Limited number of condition codes: The 8085 microprocessor has a limited number of condition codes, which
can restrict the types of conditions that can be tested.
Complex addressing modes: The addressing modes used in the branching instructions can be complex, which
can make programming more difficult.
Limited instruction set: The 8085 microprocessor has a limited instruction set, which can limit the types of
branching instructions that can be used. This can be a disadvantage for applications that require complex
program flow.
Whenever more than one I/O device is connected to a microprocessor-based system, any one of the I/O devices
may ask for service at any time. There are two methods by which the microprocessor can service these I/O
devices.
1. Polling Routine
2. Interrupts
Polling Routine
The Polling routine is a simple program that keeps a check on the occurrences of interrupts.
The polling routine will first transfer the status of the I/O port to the accumulator and then checks the content of
the accumulator to determine if the service request bit is set.
If the bit is set then the I/O port service routine is called
Interrupts
An interrupt is an external asynchronous input that informs the microprocessor to complete the instruction that
is currently executing and fetch a new routine in order to offer service to the I/O device.
Once the I/O device is serviced, the microprocessor will continue with the execution of its normal program.
Table of Contents
Basic Definitions of Interrupts
Types of Interrupts in 8085
Hardware Interrupts in 8085
Interrupt Vector Location
Software Interrupts in 8085
Comparison of Hardware interrupts and Software interrupts
Masking or unmasking of Interrupts in 8085
1. EI : Enable Interrupt
2. DI : Disable Interrupt
3. SIM : Set Interrupt Mask
4. RIM : Read Interrupt Mask
Basic Definitions of Interrupts
1. Interrupts: It is a mechanism by which an I/O device ( hardware interrupts) or an instruction
(software interrupts) can suspend the normal execution of the processor and get itself serviced.
2. Interrupt Service routine (ISR): A small program or a routine that when executed services
the corresponding interrupting source is called an ISR.
3. Vectored/Non-vectored Interrupts: If the ISR address of an interrupt is to be taken from
the interrupting source itself, it is called a non-vectored interrupt, else it is a vectored interrupt.
4. Maskable/Non-maskable Interrupt: In cases where an interrupt is masked, the
microprocessor will not respond to the interrupt even is the interrupt is activated. The interrupt
which can be masked under the software control is called as maskable Interrupt. The interrupts
which cannot be masked under the software control are called non-maskable interrupts.
Types of Interrupts in 8085
There are two types of interrupts in the 8085 microprocessor. They are:
1. Hardware Interrupts:
● The peripheral device activates the interrupt by activating the respective pin.
● In response to the interrupting request, the microprocessor completes the current
instruction execution in the main program and transfers program control to the
interrupt service routine.
● In the ISR routine, the task is completed. The task may be to read data, write data,
upload the status, update the counter, etc.
● After completing the task, the program control is transferred back to the main
program.
● These types of interrupts where the microprocessor pins are used to receive
interrupt requests are called Hardware Interrupts.
● The 8085 Microprocessor has five hardware interrupts.
1. TRAP
2. RST 7.5
3. RST 6.5
4. RST 5.5
5. INTR
2. Software Interrupts:
● In the case of software interrupts, the cause of the interrupt is the execution of the
instruction.
● The 8085 microprocessor has eight instructions. These eight instructions are RST
0 to RST 7.
● Such interrupts are called software interrupts.
● They allow microprocessors to transfer program control from the main program
to the subroutine program.
● After completing the subroutine program. the program control returns back to the
main program.
Also Read: Instruction Set of 8085 Microprocessor
Hardware Interrupts in 8085
1. TRAP :
● It is a non-maskable, edge and level-triggered interrupt.
● It is unaffected by any mask or interrupt enable.
● The TRAP signal must make a LOW to HIGH transition and remain HIGH until acknowledge.
This avoids false triggering due to noise or glitches.
● It has the highest priority among all interrupts.
● This interrupt transfers the microprocessor’s control to location 0024H.
● Application: It is used for emergency purposes like power failure, parity error checker, smoke
detector, etc.
2. RST 7.5 :
● It is a maskable, edge-triggered interrupt request input line. This interrupt is triggered at the
rising edge of the signal.
● It has the highest priority among all maskable interrupts and the second priority among all
interrupts.
● The interrupt vector location for this interrupt is 003CH.
3. RST 6.5 and RST 5.5 :
● These are level-triggered, maskable interrupt request input lines.
● RST 6.5 transfer the microprocessor’s control to location 0034H while RST 5.5 transfer the
microprocessor’s control to location 002CH.
4. INTR :
●It is a level triggered, maskable interrupt request input line.
●This interrupt works in conjunction with RST N or CALL instruction.
●The INTR logic consists of an INTE flip-flop, OR gate, and inverter. The INTR pin is logically
ANDed with the output of the INTE flip-flop.
Interrupt Vector Location
Interrupt ISR address (Vector Trigger Priority Maskable Vectored
Type Location)
1 1 N2 N1 N0 1 1 1
4. The microprocessor does not execute any interrupt The microprocessor executes either
acknowledge cycle to acknowledge this interrupt. The interrupt acknowledge cycle bus or idle
microprocessor executes a normal instruction cycle. machine cycle to acknowledge this interrupt.
6. It has the highest priority among all interrupts. The priority is lower than that of a software
interrupt.
7. It does not affect interrupt control logic. It affects interrupt control logic.
RIM Formate
● Bit D7 is status of SID pin on serial port. When RIm instruction is ecexuted the logic level of SID
pin is copied at bit D7.
● Bits D6, D5 and D4 are status of pending interrupts.
● Bits D3 to D0 are status of interrupt enable flip-flop, mask 7.5, mask 6.5 and mask 5.5. When
RIm instruction is executed the status of masking is loaded at bit D3 to D0.
Programming in 8085
Let's see some simple example to demonstrate the use of some important instructions of 8085.
The memory addresses given in the program are for a particular microprocessor kit. These addresses can be
changed to suit the microprocessor kit available in your system.
Program
3. HLT : "Stop"
3. HLT : "Stop"
Example
(2501 H) = 99H
(2502 H) = 39H
Result (2503 H) = 99H + 39H = D2H
Since,
1 0 0 1 1 0 0 1 (99H)
+ 0 0 1 1 1 0 0 1 (39H)
1 1 0 1 0 0 1 0 (D2H)
Program
1. LXI H, 2501H : "Get address of first number in H-L pair. Now H-L points to 2501H"
2. MOV A, M : "Get first operand in accumulator"
3. INX H : "Increment content of H-L pair. Now, H-L points 2502H"
4. ADD M : "Add first and second operand"
5. INX H : "H-L points 4002H"
6. MOV M, A : "Store result at 2503H"
7. HLT : "Stop"
Example
(2501 H) = 49H
(2502 H) = 32H
Result (2503 H) = 49H - 32H = 17H
Program
1. LXI H, 2501H : "Get address of first number in H-L pair. Now H-L points to 2501H"
2. MOV A, M : "Get first operand in accumulator"
3. INX H : "Increment content of H-L pair. Now, H-L points 2502H"
4. SUB M : "Subtract first to second operand"
5. INX H : "H-L points 4002H"
6. MOV M, A : "Store result at 2503H"
7. HLT : "Stop"
Add the 16-bit number in memory locations 2501H and 2502H to the 16-bit number in memory locations 2503H
and 2504H. The most significant eight bits of the two numbers to be added are in memory locations 2502H and
4004H. Store the result in memory locations 2505H and 2506H with the most significant byte in memory location
2506H.
Example
(2501H) = 15H
(2502H) = 1CH
(2503H) = B7H
(2504H) = 5AH
(2505H) = CCH
(2506H) = 76H
Program
6. HLT : "Stop"
Example
(2500H) = 19H
(2501H) = 6AH
(2504H) = 15H (2503H) = 5CH
Result = 6A19H ? 5C15H = OE04H
(2504H) = 04H
(2505H) = OEH
1. LHLD 2500H : "Get first 16-bit number in HL"
2. XCHG : "Save first 16-bit number in DE"
3. LHLD 2502H : "Get second 16-bit number in HL"
4. MOV A, E : "Get lower byte of the first number"
5. SUB L : "Subtract lower byte of the second number"
6. MOV L, A : "Store the result in L register"
7. MOV A, D : "Get higher byte of the first number"
8. SBB H : "Subtract higher byte of second number with borrow"
9. MOV H, A : "Store l6-bit result in memory locations 2504H and 2505H"
10. SHLD 2504H : "Store l6-bit result in memory locations 2504H and 2505H"
Example
(2500H) = 7FH
(2501H) = 89H
Result = 7FH + 89H = lO8H
(2502H) = 08H
(2503H) = 01H
Program