8085 Microprocessor Instruction Set
8085 Microprocessor Instruction Set
Register Addressing
In register addressing mode, the instruction specifies the name of the register in which the data is available.
Example : MOV A, B
Move the content of B-register to A-register.
Register Indirect Addressing
In register indirect addressing mode, the instruction specifies the name of the register in which the address of the
data is available. Here the data will be in memory and the address will be in a register pair.
Example : MOV A, M
The memory data addressed by HL pair is moved to A-register.
Implied Addressing
In implied addressing mode, the instruction itself specifies the data to be operated.
Example : CMA
Group IV - Branching Instructions : The instructions that are used to transfer the
program control from one memory location to another memory location are
grouped under this heading.
1. MOV Rd, Rs 0 1 DD D SS S 1 F 4T 49
2. MOV Rd, M 0 1 DD D 1 1 0 1 F, R 7T 7
3. MOV M, Rs 0 1 1 1 0 SSS 1 F, W 7T 7
4. MVI Rd, d8 0 0 DD D 1 1 0 2 F, R 7T 7
5. MVI M, d8 00 11 0 11 0 2 F, R, W 10T 1
7. LDAX rp 0 0 RP 1 0 1 0 1 F, R 7T 2
11. STAX rp 0 0 RP 0 0 1 0 1 F, W 7T 2
13. SPHL 11 11 1 00 1 1 S 6T 1
14. XCHG 11 10 1 01 1 1 F 4T 1
23. ADD M 10 0 00 11 0 1 F, R 7T 1
2. 14 Chapter 2 Instruction Set Of 8085
24. ADI d8 1 1 0 0 0 1 10 2 F, R 7T 1
26. ADC M 1 0 0 0 1 1 10 1 F, R 7T 1
27. ACI d8 1 1 0 0 1 1 10 2 F, R 7T 1
28. DAA 0 0 1 0 0 1 11 1 F 4T 1
31. SUB M 1 0 0 1 0 1 10 1 F, R 7T 1
32. SUI d8 1 1 0 1 0 1 10 2 F, R 7T 1
34. SBB M 1 0 0 1 1 1 10 1 F, R 7T 1
35. SBI d8 1 1 0 1 1 1 10 2 F, R 7T 1
38. INX rp 0 0 R P0 0 1 1 1 S 6T 4
41. DCX rp 0 0 R P1 0 1 1 1 S 6T 4
43. ANA M 1 0 1 0 0 11 0 1 F, R 7T 1
44. ANI d8 1 1 1 0 0 11 0 2 F, R 7T 1
46. ORA M 1 0 1 1 0 11 0 1 F, R 7T 1
47. ORI d8 1 1 1 1 0 11 0 2 F, R 7T 1
Microprocessor (8085) And Its Applications 2. 15
62. J<condition>
addr16 1 1 C C C0 1 0 3 F,R/F,R,R 7T/10T 8
64. C<condition> S, R or
addr16 1 1 C C C1 0 0 3 S,R,R,W,W 9T/18T 8
71. DI 1 1 110 0 1 1 1 F 4T 1
72. EI 1 1 111 0 1 1 1 F 4T 1
246
The binary codes for the symbols used in opcode of 8085 instructions are given below:
Register DDD or SSS Register RP
B 000 BC 00
C 001 DE 01
D 010 HL 10
E 011 SP 11
H 100
L 101
A 111
Status flags
Instructions
CF AF ZF SF PF
ACI d8 + + + + +
ADC reg + + + + +
ADC M + + + + +
ADD reg + + + + +
ADD M + + + + +
ADI d8 + + + + +
ANA reg 0 1 + + +
ANA M 0 1 + + +
ANI d8 0 1 + + +
CMC +
CMP reg + + + + +
CMP M + + + + +
CPI d8 + + + + +
DAA + + + + +
DAD rp +
DCR reg + + + +
DCR M + + + +
INR reg + + + +
INR M + + + +
ORA reg 0 0 + + +
ORA M 0 0 + + +
2. 18 Chapter 2 Instruction Set Of 8085
Note :
+ → Indicates that the particular flag is affected.
0 → Indicates that the particular flag is always zero.
1 → Indicates that the particular flag is always one.
TABLE - 2.3 : MEANING/EXPANSION OF MNEMONICS USED IN AN 8085 INSTRUCTION SET
A H L Memory A H L Memory
54 C0 5A 12 C0 5A
1 2 C05A 12 C05A
→
3 5 C05B 35 C05B
B H L Memory B H L Memory
74 C2 50
02 C250
74 C2 50
→ 74 C250
15 C251 15 C251
The 8-bit data (d8) given in the instruction is moved to the memory location addressed by the HL pair. No flags are affected.
Memory Memory
H L H L
28 205C E7 205C
20 5C 20 5C
3A 205D 3A 205D
Microprocessor (8085) And Its Applications 2. 23
The content of the memory location whose address is given in the instruction, is moved to accumulator. No flags are affected.
Example : LDA 205DH (A) ← (205DH)
The content of the memory location 205DH is moved to the A-register.
Before execution After execution
Memory Memory
A A
C2 15 205D 15 ← 15 205D
7 F 205E 7 F 205E
Memory L Memory
H L H
05 72 6A 1050 3D 6A 6A 1050
←
3 D 1051 3 D 1051
0 9 1052 0 9 1052
H L H L
xx yy 10 50
(some arbitrary value)
The content of the HL pair is moved to the Stack Pointer (SP). No flags are affected.
Example : SPHL (SP) ← (HL)
The content of the HL pair is copied to the Stack Pointer (SP).
Before execution After execution
SP H L SP H L
1016 C0 15 C015 C0 15
↑ ↑
The content of the HL pair is exchanged with the DE pair. No flags are affected.
Example : XCHG (E) ↔ (L) and (D) ↔ (H)
The content of the E-register is exchanged with the L-register and the content of the D-register is exchanged with the H-register.
Before execution After execution
D E H L D E H L
24 C7 A3 49 A3 49 24 C7
↑ ↑ ↑ ↑
Top of Stack
↑
↑ ↑
204F 204F
IPQ IPQ
XX XX
FD 1A 2053 FD 1A 2051
Empty
stack
XX 2050 XX 2050
Top of stack → 1 A
XX 2051 → 2051
Occupied
XX → FD
stack
2052 2052
Occupied
2053
15 2054 15 2054
2. 28 Chapter 2 Instruction Set Of 8085
D
IPQ IPQ
E SP XX 0FFF XX 0FFF
E2 5E 1002
Empty
stack
E2 1001 E 2 1001
stack
Occupied
1F 1003 1F 1003
Note : In an 8085 processor-based system when the IO devices are mapped by IO mapping then the processor can
communicate with these IO devices only by using IN and OUT instructions. The processor uses an 8-bit address to select
IO-mapped IO devices. With 8-bit address the processor can generate 2 8 = 25610 IO addresses.
The content of the memory addressed by the HL pair and the value of the carry flag (before executing this instruction)are
added to the content of A-register. After addition, the result is stored in the A-register. All flags are affected.
One byte instruction Two machine cycles: Opcode fetch - 4T
Register indirect addressing Memory read - 3T
7T
Total number of instructions = 1
The content of the register is subtracted from the content of the accumulator (A-register). After subtraction the result is
stored in the A-register. All flags are affected. The register can be any one of the general purpose register A, B, C, D, E, H or L.
Case i
Before execution Subtraction
A C
C4H = 1100 0100
C4 89
89H = 1000 1001
CF = 0
PF = 0 1's complement of 89H = 0111 0110
AF = 0 2's complement of 89H = 0111 0110 + 1
ZF = 0 = 0111 0111 = 77H
SF = 1
After execution C4H = 1100 0100
A C
3B 89 +77H = 0111 0111
1 0011 1011
CF = 0 Complement
PF = 0 Carry ↓3 B
AF = 0 0
ZF = 0 Result = 3BH
SF = 0 CF =0
Case ii
Before execution Subtraction
A C 89H = 1000 1001
89 C4
C4H = 1100 0100
CF = 0 1's complement of C4H = 0011 1011
PF = 0
AF = 0 2's complement of C4H = 0011 1011 + 1
ZF = 1 = 0011 1100 = 3CH
SF = 1
2. 32 Chapter 2 Instruction Set Of 8085
Note : The 8085 microprocessor per forms 2's complement subtraction. But after subtraction, it will complement
the carry alone. In 2's complement subtraction, if CF =1, then the result is positive and if CF =0, then the result is
negative. Since, the 8085 processor complements the carry after subtraction, here if CF = 0, then the result is positive and
if CF = 1, then the result is negative. If the result is negative, then it will be in 2's complement form.
8. SUI d8 ( A ) ← (A) – d8
The 8-bit data given in the instruction is subtracted from the A-register (accumulator). After subtraction, the result is stored
in the A-register. All flags are affected.
Two byte instruction Two machine cycles : Opcode fetch - 4T
Immediate addressing Memory read - 3T
7T
Total number of instructions = 1
The 8-bit data given in the instruction and the value of carry (before executing this instruction) are subtracted from
accumulator. After subtraction, the result is stored in the accumulator. All flags are affected.
The content of the memory addressed by HL and the value of carry (before executing this instruction) are subtracted from
accumulator (A-register). After subtraction, the result is stored in the A-register. All flags are affected .
13. DAA
(DAA - Decimal Adjust Accumulator)
After BCD addition, the DAA instruction is executed to get the result in BCD. When DAA instruction is executed, the content
of the accumulator is altered or adjusted as explained below :
i) If the sum of the lower nibbles exceeds 09H or auxiliary carry is set, then a correction 06H (0110) is added to sum
of lower nibbles.
ii) If the sum of the upper nibbles exceeds 09H or carry is set, then a correction 06H (0110) is added to sum of upper nibble.
After executing this instruction all flags are modified to indicate the status of the result.
One byte instruction One machine cycle: Opcode fetch - 4T
Implied addressing
Total number of instructions = 1
The content of the register pair is added to the content of the HL pair. After addition, the result is stored in the HL pair. Only
the carry flag is affected. The register pair can be BC, DE, HL or SP.
After execution
FAH = 1111 1010
HL Memory + FFH = 1111 1111
2010 F9 2010 1 1111 1001
CF = 0 02 2011 F 9
PF = 1 Carry is discarded
AF = 1
ZF = 0
SF = 1
The content of the register pair is incremented by one. The register pair can be BC, DE, HL or SP. No flags are affected.
The content of the register pair is decremented by one. The register pair can be BC, DE, HL or SP. No flags are affected.
The content of the register is logically ANDed bit by bit with the content of the accumulator. In bit by bit AND operation, the
bit D0 of register is ANDed with the bit D0 of A-register, the bit D1 of register is ANDed with bit D1 of A-register, and so on. The register
can be any one of the general purpose register A, B, C, D, E, H or L. After execution of the instruction, carry flag is always reset and
auxiliary carry flag is always set. Other flags are altered (according to the results).After AND operation, result is stored in accumulator.
Example : ANA E (A) ← (A) & (E)
The content of E-register is logically ANDed bit by bit with the content of accumulator.
Before execution AND operation After execution
The content of the memory addressed by the HL pair is logically ANDed bit by bit with the content of the accumulator. The
result is stored in the accumulator. After execution, CF = 0 and AF = 1. Other flags are affected .
The content of the register is logically ORed bit by bit with the content of the accumulator. In bit by bit OR operation, the bit
D0 of the register is ORed with bit D0 of the A-register, the bit D1 of the register is ORed with bit D1 of the A-register, and so on. The
register can be any one of the general purpose register A, B, C, D, E, H or L. After execution of the instruction, both the carry and
auxiliary flags are always reset (AF = 0, CF = 0). Other flags are modified (according to the result). After OR operation, the result is
stored in the accumulator.
One byte instruction One machine cycle: Opcode fetch - 4T
Register addressing
2. 38 Chapter 2 Instruction Set Of 8085
12. CMP M (A) – (M) ⇒ Modify flags or (A) – ((HL)) ⇒ Modify flags.
The content of the memory addressed by HL pair is compared with the accumulator. The comparison is performed by subtracting the
content of memory from the A-register. The subtraction is performed in the ALU and the result is used to modify flags and then [Link]
execution of the instruction, the content of the accumulator and the memory are not [Link] flags are affected by this instruction.
The status of carry and zero flag after comparison are given below:
i) If (A) < (M) then the carry flag is set (i.e., CF = 1).
ii) If (A) > (M) then the carry flag is reset or cleared (i.e., CF = 0).
iii) If (A) = (M) then the zero flag is set (i.e., ZF = 1).
Example : CMP M
Let the content of the HL pair be C050H. Let the content of the memory location C050H be 7AH. The content of the memory
location C050H is compared with the content of the accumulator. Only flags are altered. The content of the accumulator
and the memory remains the same.
Before After
Comparison
execution execution
A HL 25H = 0010 0101 A HL
25 C050 7AH = 0111 1010 25 C050
Memory 1'complement of 7AH= 1000 0101 Memory
7A C050 2'complement of 7AH = 1000 0101 +1 7A C050
10 C051 = 1000 0110 =86H 10 C051
CF = 0 25H = 0010 0101 CF = 1
PF = 0 +86H = 1000 0110 PF = 0
AF = 0 AF = 0
ZF = 0 0 1010 1011
ZF = 0
SF = 0 Complement
Carry
↓ A B SF = 1
1
The content of the A-register is rotated left by one bit and the left most bit of A-register is rotated to the carry. [The left
most bit is most significant bit.] Only the carry flag is affected.
Example : RLC
Before execution Rotation After execution
CF A CF CF A
1 0 0 1 1 0 0 1 0
1 32 0 64
A CF
ß A
D7 D6 D5 D4 D3 D2 D1 D0 0 0 1 1 0 0 1 0 0 D7 D6 D5 D4 D3 D2 D1 D0
6 4
One byte instruction One machine cycle: Opcode fetch - 4T
Implied addressing
CF
ß A
A
D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0 1 1 0 0 1 D7 D6 D5 D4 D3 D2 D1 D0
1 9
Example : RAR
Before execution Rotation After execution
CF A CF A
CF
1 32 0 99
1 0 0 1 1 0 0 1 0
A CF
ß A
D7 D6 D5 D4 D3 D2 D1 D0 1 1 0 0 1
D7 D6 D5 D4 D3 D2 D1 D0
0 1 0 0
9 9
A CF
ß A
D7 D6 D5 D4 D3 D2 D1 D0 0 1 1 0 0 1 0 1 D7 D6 D5 D4 D3 D2 D1 D0
0
6 5
One byte instruction One machine cycle: Opcode fetch - 4T
Implied addressing
2. J <condition> addr16
If <condition> is TRUE then,
(PC) ← addr16
It is conditional jump instruction. The conditional jump instruction will check a flag condition. If the flag condition is true,
then the address given in the instruction is moved to the program counter. Thus the program control is branched to the jump
address. If the flag condition is false, then the next instruction is executed.
2. 44 Chapter 2 Instruction Set Of 8085
Three byte instruction Two or three machine cycles: Condition False Condition True
Immediate addressing Opcode fetch - 4T Opcode fetch - 4T
Memory read - 3T Memory read - 3T
Memory read - 3T
7T 10T
4. C<condition> addr16
If <condition> is TRUE then,
(SP) ← (SP) – 1 ; ((SP)) ← (PC)H
(SP) ← (SP) – 1 ; ((SP)) ← (PC)L
(PC) ← addr16
It is conditional subroutine call instruction. The conditional CALL instruction will check for a flag condition. If the flag
condition is true, then the address of the next instruction is pushed to the stack and the call address (address given in the
instruction) is loaded in the program counter. Now, the processor will start executing the instructions stored in this address. If the
flag condition is false, then the next instruction is executed.
There are eight conditional CALL instructions. These are:
i) CZ addr16 ;Call on Zero - Call if zero flag = 1.
ii) CNZ addr16 ;Call on Not Zero - Call if zero flag = 0.
iii) CC addr16 ;Call on Carry - Call if carry flag = 1.
iv) CNC addr16 ;Call on No Carry - Call if carry flag = 0.
v) CM addr16 ;Call on Minus - Call if sign flag = 1.
vi) CP addr16 ;Call on Positive - Call if sign flag = 0.
vii) CPE addr16 ;Call on Parity Even - Call if parity flag = 1.
viii) CPO addr16 ;Call on Parity Odd - Call if parity flag = 0.
Microprocessor (8085) And Its Applications 2. 45
Three byte instruction Two or five machine cycles: Condition False Condition True
Immediate addressing Opcode fetch - 6T Opcode fetch - 6T
Memory read - 3T Memory read - 3T
9T Memory read - 3T
Memory write - 3T
Memory write - 3T
18T
6. R<condition>
If <condition> is TRUE then,
(PC)L ← ((SP)) ; (SP) ← (SP) + 1
(PC)H ← ((SP)) ; (SP) ← (SP) + 1
It is conditional return instruction.
In a conditional return instruction a flag condition is tested. If the flag condition is true, then the program control return to
main program by poping the top of the stack to the program counter. If the flag condition is false, then the next instruction is
executed.
There are eight conditional return instructions:
i) RZ ;Return on Zero - Return if zero flag = 1.
ii) RNZ ;Return on Not Zero - Return if zero flag = 0.
iii) RC ;Return on Carry - Return if carry flag = 1.
iv) RNC ;Return on No Carry - Return if carry flag = 0.
v ) RM ;Return on Minus - Return if sign flag = 1.
vi) RP ;Return on Positive - Return if sign flag = 0.
vii) RPE ;Return on Parity Even - Return if parity flag = 1.
viii) RPO ;Return on Parity Odd - Return if parity flag = 0.
One byte instruction One or three machine cycles: Condition False Condition True
Register indirect addressing Opcode fetch - 6T Opcode fetch - 6T
Memory read - 3T
Memory read - 3T
12T
2. 46 Chapter 2 Instruction Set Of 8085
7. RST n
It is a restart instruction. The restart instructions are also called software interrupts. Each restart instruction has a vector
address. The vector address is fixed by the manufacturer (INTEL).
When a restart instruction is executed, the content of the program counter is pushed to the stack and the vector address
is loaded in the program counter. The vector address is internally generated (computed) by the processor. The vector address for
RST n is obtained by multiplying n by 8. Thus the program control is branched to a subroutine program stored in this vector address.
One byte instruction Three machine cycles: Opcode fetch - 6 T
Register indirect addressing Memory write - 3 T
Memory write - 3 T
12T
There are eight restart instructions.
RST 0 RST 1 RST 2 RST 3 RST 4 RST 5 RST 6 RST 7
The vector addresses for the restart instructions are listed in the table given below :
The content of the HL register pair is moved to the program counter. Since this instruction alters the content of the program
counter, the program control is transferred to a new address. This instruction is used by the system designer to implement the
system subroutine to execute a program.
One byte instruction One machine cycle: Opcode fetch - 6T
Implied addressing
2. EI
(EI - Enable Interrupts)
This instruction is used (or executed) to allow the interrupts after disabling. (The interrupts except TRAP are disabled after
processor reset or after execution of DI instruction. When we want to allow the interrupts, we have to execute EI instructions.)
One byte instruction One machine cycle: Opcode fetch - 4T
3. SIM
(SIM - Set Interrupt Mask)
The SIM instruction is used to mask the hardware interrupts RST 7.5, RST 6.5 and RST 5.5. It is also used to send data
through the SOD line. (SOD: Serial Output Data pin of the 8085 processor.) The execution of SIM instruction uses the content of the
accumulator to perform the following functions:
i) Program the interrupt mask for the hardware interrupts RST 5.5, RST 6.5 and RST 7.5.
ii) Reset the edge-triggered RST 7.5 input latch.
iii) Load the SOD output latch.
The bits in the accumulator before execution of the SIM instruction are defined as shown in the Fig. 2.12.
D7 D6 D5 D4 D3 D2 D1 D0
4. RIM
(RIM - Read Interrupt Mask)
The RIM instruction is used to check whether an interrupt is masked or not. It is also used to read data from the SID line.
(SID: Serial Input Data pin of 8085 processor).
When a RIM instruction is executed, the accumulator is loaded with 8-bit data. The 8-bit data in the accumulator (content
of accumulator) can be interpretted as shown in Fig. 2.13.
Bits D0, D1 and D2 provide the mask status of the RST 5.5, RST 6.5 and RST 7.5 interrupts respectively. If the mask bit
corresponding to a particular RST is "1", then the interrupt is masked and if the mask bit is "0" then the interrupt is unmasked.
If the interrupt enable bit (D3) is "0", the 8085's maskable interrupts are disabled. The interrupts are enabled if this bit is "1".
A "1" in a particular interrupt pending bit indicates that an interrupt is being requested on the identified RST line. When this
bit is "0", no interrupt is waiting to be serviced. The serial input data (bit D7) indicate the value of the signal at the SID pin.
One byte instruction One machine cycle: Opcode fetch - 4T
2. 48 Chapter 2 Instruction Set Of 8085
D7 D6 D5 D4 D3 D2 D1 D0
5. HLT
(HLT - Halt program Execution)
This instruction is placed at the end of the program. When this instruction is executed, the processor suspends program
execution and bus will be in idle state.
One byte instruction Two machine cycle: Opcode fetch - 3T
Bus idle - 2T
5T
6. NOP
(NOP - No operation)
The NOP is a dummy instruction, it neither achieves any result nor affects any CPU registers. This is an useful instruction
for producing software delay and reserve memory spaces for future software modifications.
One byte instruction One machine cycle : Opcode fetch - 4T