Coa Unit 3 Instruction Sets
Coa Unit 3 Instruction Sets
INSTRUCTION SET
By
Hena Vadi
Computer Department
Instruction Set of 8085
An instruction is a binary pattern designed inside a
microprocessor to perform a specific function.
The entire group of instructions that a
microprocessor supports is called Instruction
Set.
8085 has 246 instructions.
Each instruction is represented by an 8-bit binary
value.
These 8-bits of binary value is called Op-Code or
Instruction Byte.
Classification of Instruction Set
A 20 B MOV B,A A 20 B 20
A F A F
B 30 C B 30 C
MOV M,B
D E D E
H 20 L 50 H 20 L 50 30
A F A F
B C B C 40
MOV C,M
D E D E
H 20 L 50 40 H 20 L 50 40
MVI-Move immediate 8-bit
Opcode Operand
A F A F
B C MVI B,60H B 60 C
D E D E
H L H L
204FH 204F
HL=2050 HL=2050 40
MVI M,40H
2051H 2051H
LDA-Load accumulator
Opcode Operand
A A 30
LDA 2000H
2000H
30 2000H 30
LDAX-Load accumulator indirect
Opcode Operand
LDAX B/D Register Pair
Example: LDAX D
BEFORE EXECUTION AFTER EXECUTION
A F A 80 F
B C B C 80
2030H 80 2030H
LDAX D
D 20 E 30 D 20 E 30
LXI-Load register pair immediate
Opcode Operand
LXI Reg. pair, 16-bit data
A F A F
B C B C
H L H 90 L 30
LHLD-Load H and L registers direct
Opcode Operand
LHLD 16-bit address
A F A 80 F
B C
8500H 60
B C
2030H 00
H L 85 H 85 L 00
M=60
STA-Store accumulator direct
Opcode Operand
STA 16-bit address
A 50 A
50
2000H 2000H 50
STAX-Store accumulator indirect
Opcode Operand
Example: STAX B
STAX B
BEFORE EXECUTION AFTER EXECUTION
B 85 C 00
8500H 0A
A=0AH
SHLD-Store H and L registers direct
Opcode Operand
SHLD 16-bit address
D E
8500H 80
H 70 L 80
8501H 70
XCHG-Exchange H and L with D and E
Opcode Operand
XCHG None
Example: XCHG
BEFORE EXECUTION AFTER EXECUTION
D 20 E 40 D 70 E 80
XCHG
H 70 L 80 H 20 L 40
SPHL-Copy H and L registers to the
stack pointer
Opcode Operand
SPHL None
Example: SPHL
BEFORE EXECUTION
SP
H 25 L 00
SPHL
AFTER EXECUTION
SP 2500
H 25 L 00
XTHL-Exchange H and L with top of
stack
Opcode Operand
XTHL None
Example: XTHL
L=SP
H=(SP+1)
SP 2700
2700H 50 SP 2700
40
2700H
H 30 L 40
H 60 L 50
2701H 60 30
2701H
XTHL
2702H 2702H
PCHL- Load program counter with H-L contents
Opcode Operand
PCHL None
Example: PCHL
PUSH-Push register pair onto stack
Opcode Operand
PUSH Reg. pair
Example: IN 8C H
BEFORE EXECUTION
PORT 10 A
80H
IN 80H
AFTER EXECUTION
PORT 10 A 10
80H
OUT- Copy data from accumulator to a
port with 8-bit address
Opcode Operand
OUT 8-bit port address
PORT 10 A 40
50H
OUT 50H
AFTER EXECUTION
PORT 40 A 40
50H
2.Arithmetic Instructions
These instructions performs the operations
like:
◦ Addition
◦ Subtract
◦ Increment
◦ Decrement
ADD
Opcode Operand Description
ADD R Add register or memory to
M accumulator
B C B. C 05
05
D E
ADD C D E
H L
H L A=A+C
04+05=09
BEFORE EXECUTION
AFTER EXECUTION
A 04 14
ADD M A
B C B C
D E
A=A+M D E
10
H 20 L 50
10 H 20 L 50
CY 01
A 50 A 56
B C B C 20
05 ADC C D E
D E A=A+C+CY H L
H L
50+05+01=56
CY 1
A 06 2050H 30 ADC M A 37 2050H 30
H 20 L 50
A=A+M+CY
H 20 L 50
06+1+30=37
ADI
Opcode Operand Description
ADI 8-bit data Add immediate to accumulator
Example: ADI 45 H
BEFORE EXECUTION AFTER EXECUTION
A 03 ADI 05H A 08
A=A+DATA(8)
03+05=08
ACI
Opcode Operand Description
ACI 8-bit data Add immediate to
accumulator with carry
The 8-bit data and the Carry Flag (CY) are added to the
contents of accumulator.
Example: ACI 45 H
BEFORE EXECUTION AFTER EXECUTION
CY 1
ACI 20H A 26
A 05 A=A+DATA
05+20+1=26
(8)+CY
DAD
Opcode Operand Description
DAD Reg. pair Add register pair to H-L pair
D 12 E 34 D 12 E 34
H 23 L 45
DAD D H 35 L 79
1234
2345 +
------- DAD D HL=HL+DE
3579 DAD B HL=HL+BC
SUB
Opcode Operand Description
SUB R Subtract register or memory
M from accumulator
B C B. C 04
04
D E
SUB C D E
H L
H L A=A-C
09-04=05
BEFORE EXECUTION
AFTER EXECUTION
A 14 A 04
SUB M
B C B C
D E
A=A-M D E
10
H 20 L 50
10 H 20 L 50
CY 01
A 08 A 02
B C B C 05
05 SBB C D E
D E
H L
A=A-C-CY H L
08-05-01=02
CY 01
A 06 2050H 02 SBB M A 03 2050H 02
H 20 L 50 A=A-M-CY H 20 L 50
06-02-1=03
SUI
Opcode Operand Description
A 08 SUI 05H A 03
A=A-DATA(8)
08-05=03
SBI
Opcode Operand Description
SBI 8-bit data Subtract immediate from
accumulator with borrow
The 8-bit data and the Borrow Flag (i.e. CY) is subtracted
from the contents of the accumulator.
The result is stored in accumulator.
All flags are modified to reflect the result of subtraction.
Example: SBI 45 H
CY 1 SBI 20H
A 25 A=A-DATA (8)-CY
A 04
25-20-01=04
INR
Opcode Operand Description
INR R Increment register or
M memory by 1
A A
B 10 C INR B B 11 C
D
H
E
L
B=B+1 D
H
E
L
10+1=11
BEFORE EXECUTION AFTER EXECUTION
H 20 L 50
2050H 10 H 20 L 50
11 2050H
INR M
M=M+1 10+1=11
INX
Opcode Operand Description
INX R Increment register pair by 1
SP SP
B C B C
D E INX H D E
H 10 L 20 RP=RP+1 H 10 L 21
1020+1=1021
DCR
Opcode Operand Description
DCR R Decrement register or
M memory by 1
A A
B C B C
D E 20
DCR E D E 19
H L R=R-1 H L
20-1=19
BEFORE EXECUTION AFTER EXECUTION
H L
H
20
L
50
2050H
21
DCR M
20 50 2050H 20
M=M-1 21-1=20
DCX
Opcode Operand Description
SP SP
B C B C
D E DCX H D E
H 10 L 21 RP=RP-1 H 10 L 20
3.Logical Instructions
Theseinstructions perform logical operations on data
stored in registers, memory and status flags.
0101 0101=55H
CY AC 1011 0011=B3H CY 0 AC 1
0001 0001=11H
A 55 2050H B3 A 11 2050H B3
H 20 L 50 ANA M H 20 L 50
A=A AND M
Opcode Operand Description
1011 0011=B3H
0011 1111=3FH
0011 0011=33H
CY AC CY 0 AC 1
ANI 3FH
A B3 A=A AND DATA(8) A 33
Opcode Operand Description
ORA R Logical OR register or memory with
M accumulator
Example:ORA B or ORA M.
1010 1010=AAH
0001 0010=12H
BEFORE EXECUTION AFTER EXECUTION
1011 1010=BAH
CY AC CY 0 AC 0
ORA B
A=A or R
A AA A BA
B 12 C B 12 C
D E D E
H L H L
0101 0101=55H
1011 0011=B3H
BEFORE EXECUTION AFTER EXECUTION
1111 0111=F7H
CY AC CY 0 AC 0
ORA M
A=A or M
A 55 2050H B3 A F7 2050H B3
H 20 L 50 H 20 L 50
Opcode Operand Description
CY AC CY 0 AC 0
ORI 08H
A B3 A=A or DATA(8) A BB
Opcode Operand Description
CY AC CY 0 AC 0
A AA A 87
B 10 C 2D B C 2D
D E XRA C D E
H L A=A xor R H L
0101 0101=55H
BEFORE EXECUTION 1011 0011=B3H AFTER EXECUTION
1110 0110=E6H
CY AC CY 0 AC 0
XRA M
2050H B3 A E6 2050H B3
A 55
A=A xor M
H 20 L 50 H 20 L 50
Opcode Operand Description
CY AC CY 0 AC 0
XRI 39H
A B3 A=A xor DATA(8) A 8A
Compare
Any8-bit data, or the contents of register, or
memory location can be compares for:
◦ Equality
◦ Greater Than
◦ Less Than
10<20:CY=01
BEFORE EXECUTION AFTER EXECUTION
A>M: CY=0
A=M: ZF=1
CY Z A<M: CY=1 CY 0 Z 1
A B8 2050H B8 A B8 2050H B8
CMP M
H 20 L 50 H 20 L 50
A-M
B8=B8 : ZF=01
Opcode Operand Description
CY Z CY 0 Z
CPI 30H
A BA
A-DATA A BA
BA>30 : CY=00
Rotate
Each bit in the accumulator can be shifted either
left or right to the next position.
Opcode Operand Description
RLC None Rotate accumulator left
CY B7 B6 B5 B4 B3 B2 B1 B0
AFTER EXECUTION
B7 B6 B5 B4 B3 B2 B1 B0 B7
Opcode Operand Description
RRC None Rotate accumulator right
B7 B6 B5 B4 B3 B2 B1 B0 CY
AFTER EXECUTION
B0 B7 B6 B5 B4 B3 B2 B1 B0
Opcode Operand Description
RAL None Rotate accumulator left
through carry
Bit D7 is placed in the Carry flag, and the Carry flag is placed
in the least significant position D0.
Example: RAL.
BEFORE EXECUTION
CY B7 B6 B5 B4 B3 B2 B1 B0
AFTER EXECUTION
B7 B6 B5 B4 B3 B2 B1 B0 CY
Opcode Operand Description
RAR None Rotate accumulator right
through carry
B7 B6 B5 B4 B3 B2 B1 B0 CY
AFTER EXECUTION
CY B7 B6 B5 B4 B3 B2 B1 B0
Opcode Operand Description
A 00 A FF
Opcode Operand Description
CMC None Complement carry
C 0 C 1
Opcode Operand Description
STC None Set carry
• Symbolic Representation:
• Forward Jump
• Backward Jump
Unconditional Jump
• Forward Jump:
• JMP Next
• ….
• ….
• ….
• Next : ADD B
• Backward Jump:
• Next : ANA C
• ….
• ….
• ….
• JMP Next
Conditional JUMP
• Transfer control to specific instruction if Condition is
Fulfilled, otherwise control transfer to next instruction.
• Symbolic Representation:
• If Condition is True
• Then PC <- (Byte3)(Byte 2)
Conditional Jump
• Forward Jump: Backward Jump:
• CMP B • Next : INX H
• JC Next • ….
• MOV A,B • ….
• ….
• DCR C
• JNZ Next
• ….
• MOV M,A
• Next : MOV M,A
• …..
Opcode Operand Description
No operation is performed.
The instruction is fetched and decoded but no operation is
executed.
Example: NOP
Opcode Operand Description
HLT None Halt
Books:
Microprocessors and microcontrollers by krishnakanth