Professional Documents
Culture Documents
4CS3 MPI Unit 2
4CS3 MPI Unit 2
(4CS3-04)
UNIT 2
MOV Rd, Rs
M, Rs
Rd, M
• This instruction copies the contents of the source register
into the destination register(contents of the source register
are not altered).
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 immediate8-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
30
LDA
2000H 30
2000H
2000H
LDAX-Load accumulator indirect
Opcode Operand
LDA X 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
O pcode O perand
LXI Reg. pair, 16-bit data
A F A 80 F
B C B C
2030H 30 9030H 50
LXI H,
H L 2030
2031H 90 H 90 L 30
M=50
LHLD-Load H andL registersdirect
Opcode Operand
LHLD 16-bit address
A F A 80 F
B C
2030H 00 B C
8500H
60
LHLD
H L 2030
85 H 85 L 00
M=60
STA-Store accumulator direct
A 50 A
50
STA 50
2000H 2000H
2000H
STAX-Store accumulator indirect
O pcode Operand
B 85 C 00
8500H 1A
A=1A H STAX B
SHLD-Store H andL registersdirect
Opcode Operand
SHLD 16-bit address
D E
8500H 80
H 70 L 80 SHL
8501H 70
D
8500
XCHG-Exchange H andL with D andE
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 N one
Example: SPHL
BEFORE EXECUTION
SP
H 25 L 00
SPHL
AFTER EXECUTION
SP 2500
H 25 L 00
XTHL- Exchange H andL with topof 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 L
2701H 60 50
30
60 2701H
XTHL
2702H 2702H
PUSH-Push register pair onto stack
Opcode Operand
PUSH Reg. pair
Example: IN 8C H
BEFOREEXECUTION
POR 10 A
T
80H
IN 80H
AFTEREXECUTION
POR 10 A 10
T
OUT- Copy datafrom accumulator to a port
Opcode Operand
OUT 8-bit port address
POR
10 A 40
T 50H
OUT 50H
AFTEREXECUTION
POR 40 A 40
T 50H
2.Arithmetic Instructions
Example: A D D B or A D D M
BEFOREEXECUTION AFTEREXECUTION
A 04 A. 09
B C B. C 05
05
D E
ADDC D E
H L
H L A=A+C
04+05=09
BEFOREEXECUTION
AFTEREXECUTION
A 04 14
ADDM A
B C B C
D E
A=A+M D E
H 20 L 50 50 10
10 H 20 L
• The contents of register or memory and Carry Flag (CY) are added to the
contents of accumulator.
Example: A DC B or A DC M
BEFOREEXECUTION AFTEREXECUTION
CY 01
A 50
A 56
B C B C 20
05 ADCC D E
D E A=A+C+CY H L
H L
50+05+01=56
BEFOREEXECUTION AFTEREXECUTION
CY 1
A 06 2050H 30 ADCM A 37 2050H
30
H 20 L 50
A=A+M+CY
H 20 L 50
06+1+30=37
AD I
Example: ADI 45 H
BEFOREEXECUTION AFTEREXECUTION
A 03 ADI 05H A 08
A=A+DATA(8)
03+05=08
• The 8-bit data and the Carry Flag (CY) are added to the
contents of accumulator.
CY 1 ACI 20H
A 05 A=A+DATA A 26
(8)+CY 05+20+1=26
DA D
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
Subtraction
B C B. C 04
04
D E
SUBC D E
H L
H L A=A-C
09-04=05
BEFOREEXECUTION
AFTEREXECUTION
A 14 04
SUBM A
B C B C
D E
A=A-M D E
H 20 L 50 50 10
10 H 20 L
CY 01
A 08
A 02
B C B C 05
05 SBBC D E
D E
H L
A=A-C-CY H L
08-05-01=02
BEFOREEXECUTION AFTEREXECUTION
CY 1
A 06 2050H 02 SBBM 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 D escription
SBI 8-bit data Subtract immediate from
accumulator with borrow
Example: SBI 45 H
collected by C.GokulAP/EEE,VCET
BEFOREEXECUTION AFTEREXECUTION
CY 1
SBI 20H
A 25 A=A-DATA A 04
(8)-CY
25-20-01=04
Increment / Decrement
• The 8-bit contents of a register or a memory
location can be incremented or decremented
by 1.
• The 16-bit contents of a register pair can be
incremented or decremented by 1.
• Increment or decrement can be performed on
any register or a memory location.
Increment
• AND operation
• OR operation
• XOR operation
• Equality
• Greater Than
• Less Than
• The contents of the accumulator are logically ORed with the contents of the
register or memory.
• The contents of the accumulator are XORed with the contents of the
register or memory.
• The result is placed in the accumulator.
• If the operand is a memory location, its address is specified by
the contents of H-L pair.
• S, Z, P are modified to reflect the result of the operation.
• Example: XRA B or XRA M.
Logical Instructions
Opcode Operand Description
XRI 8-bit data XOR immediate with accumulator
RST 1 0008 H
RST 2 0010 H
RST 3 0018 H
RST 4 0020 H
RST 5 0028 H
RST 6 0030 H
RST 7 0038 H
Control Instructions
• The control instructions control the operation of microprocessor.
Control Instructions
Opcode Operand Description
NOP None No operation
• No operation is performed.
• The instruction is fetched and decoded but no
operation is executed.
• Example: NOP
Control Instructions
Opcode Operand Description
HLT None Halt
▶ Register
▶ Memory Location
▶ 8-bit number
The method by which the address of source of data and the address of the
destination of the result is given in the instruction are called the Addressing
modes.
8085 uses the following addressing
modes: