Professional Documents
Culture Documents
DECIMA L
= 10 = A = 11 = B = 12 = C = 13 = D = 14 = E = 15 =
BEFORE EXECUTION A 20 B
AFTER EXECUTION
MOV B,A
20
20
A B D H 20 30
F C E L 50
F 30 C E 20 L 50 30
MOV M,B
B D H
A B D H 20
F C E L 50 40
F C E 20 L 50 40 40
MOV C,M
B D H
BEFORE EXECUTION A B D H F C E L
AFTER EXECUTION A F 60 C E L
MVI B,60H
B D H
AFTER EXECUTION
MVI M,40H
HL=2050 H 2051H
40
BEFORE EXECUTION A
AFTER EXECUTION A 30
30 2000H
LDA 2000H
30 2000H
BEFORE EXECUTION A F
AFTER EXECUTION A 8 0 F
2030 H
D 2 0 E 3 0
80
LDAX D
2030 H
3 0
80
2 0
BEFORE EXECUTION A 50
AFTER EXECUTION A 50
2000H
STA 2000H
50 2000H
BEFORE EXECUTION
AFTER EXECUTION A 5 0 1 0 F
5 0 1 0
2 0
1020H
STAX B
2 0
50
1020H
BEFORE EXECUTION H 30 L 60 H
AFTER EXECUTION 30 L 60
204FH
204FH
60
2500H
SHLD 2500H
2500H
30
2502H
2502H
BEFORE EXECUTION
AFTER EXECUTION
20
40
70
80
70
80
XCHG
20
40
SPHL
Move data from H-L pair to the Stack Pointer (SP) This instruction loads the contents of H-L pair into SP. Example: SPHL
BEFORE EXECUTION
SP H 25 L 00
SPHL
AFTER EXECUTION
SP H 25 L 2500 00
L=SP H=(SP+1)
BEFORE EXECUTION AFTER EXECUTION
S P H 3 0
2700 L 4 0
50
S P H
2700 L 60 50
40
60
30
XTHL
BEFORE EXECUTION
AFTER EXECUTION
PC H 60 L 00
PC
6000 L 60 00
PCHL
BEFORE EXECUTION
PORT 80H 10 A
IN 80H
AFTER EXECUTION
PORT 80H 10 A 10
BEFORE EXECUTION
PORT 50H 10 A 40
OUT 50H
AFTER EXECUTION
PORT 50H 40 A 40
Arithematic Instructions
These instructions perform the operations like: Addition Subtraction Increment Decrement
ADD R ADD M
The contents of register or memory are added to the contents of accumulator. The result is stored in accumulator. If the operand is memory location, its address is specified by H-L pair. Example: ADD C or ADD M
BEFORE EXECUTION A B D H 20 C E L 30
AFTER EXECUTION A 50 C E L 30
ADD C A=A +R
A B D H
B D H
BEFORE EXECUTION A B D H 20 20 C E L 50
AFTER EXECUTION 30 C E 20 L 50
2050
1 0
ADC R ADC M
The contents of register or memory and Carry Flag (CY) are added to the contents of accumulator. The result is stored in accumulator. If the operand is memory location, its address is specified by H-L pair. All flags are modified to reflect the result of the addition. Example: ADC C or ADC M
BEFORE EXECUTION CY A B D H 1 50 C E L 20
AFTER EXECUTION CY A 0 71 C E L 20
ADC C A=A+R+ CY
B D H
ADC M A=A+M+C Y
A H
The 8-bit data is added to the contents of accumulator. The result is stored in accumulator. Example: ADI 10 H
BEFORE EXECUTION
AFTER EXECUTION
50
60
The 8-bit data and the Carry Flag (CY) are added to the contents of accumulator. The result is stored in accumulator. Example: ACI 20 H
BEFORE EXECUTION
AFTER EXECUTION
CY A
1 30
CY A
0 51
BEFORE EXECUTION
AFTER EXECUTION
CY SP B D H
CY SP C
10 20
E L
20 50
DAD D HL=HL +R
B D H 10 30
C E L 20 70
BEFORE EXECUTION A B D H 50 30 C E L
AFTER EXECUTION A 20 30 C E L
SUB B A=A-R
B D H
BEFORE EXECUTION
AFTER EXECUTION
A H
50 L 10
10 1020H
SUB M
A H
40 L 10
10 1020H
20
20
BEFORE EXECUTION CY A B D H 1 40 C E L 20
AFTER EXECUTION CY 0 19 C E L 20
SBB C A=A-R-CY
A B D H
BEFORE EXECUTION CY A H 20 1 50 L 50 10
AFTER EXECUTION CY 0 39 L 20 50
2050H
SBB M A=A-MCY
A H
2050H
10
BEFORE EXECUTION
AFTER EXECUTION
CY A
1 50
CY A
0 29
BEFORE EXECUTION A B D H H 10 C E L L
AFTER EXECUTION A B D H 11 C E L
INR B R=R +1
BEFORE EXECUTION
AFTER EXECUTION
H 20
L 50
2050 H
30
INR M M=M
H 20
L 50
31
2050 H
INX Rp
The contents of register pair are incremented by 1. The result is stored in the same place. Example: INX H
BEFORE EXECUTION
AFTER EXECUTION
SP B D H 10 C E L 20
SP B C E 11 L 21
INX H RP=RP +1
D H
DCR R DCR M
The contents of register or memory location are decremented by 1. The result is stored in the same place. If the operand is a memory location, its address is specified by the contents of H-L pair. Example: DCR E or DCR M
BEFORE EXECUTION
AFTER EXECUTION
A B D H C E L 20
DCR E R=R1
B D H
C E L 19
BEFORE EXECUTION
AFTER EXECUTION
H 20
L 50
2050 H
21
L 20 50 2050 H
20
DCR M M=M1
DCX Rp
The contents of register pair are decremented by 1. The result is stored in the same place. Example: DCX D
BEFORE EXECUTION
AFTER EXECUTION
SP B D H 10 C E L 20
SP B C 10 E L 19
DCX D RP=RP1
D H
ANA R ANA M
AND specified data in register or memory with accumulator. Store the result in accumulator (A). Example: ANA B, ANA M
BEFORE EXECUTION C Y A B D H H AA 10 0F C E L L A C
AFTER EXECUTION C Y A B D H 0 A C 0A 0F C E L 1
C Y A H 55
A C
20 L
AND 8-bit data with accumulator (A). Store the result in accumulator (A) Example: ANI 3FH
BEFORE EXECUTION
AFTER EXECUTION
C Y A B3
A C
C Y A
0 33
A C
XOR specified register with accumulator. Store the result in accumulator. Example: XRA C
BEFORE EXECUTION
AFTER EXECUTION
C Y A B D H H AA 10
A C C E L L 2D
C Y A B D H
0 A C 87 C E L
2D
XRA M
XOR data in memory (memory location pointed by H-L pair) with Accumulator. Store the result in Accumulator. Example: XRA M
BEFORE
AFTER EXECUTION
C Y A H 55 20
A C L 50
2050H
B3
C Y A H
0 A C E6 20 L
0 B3 2050H 50
XOR 8-bit immediate data with accumulator (A). Store the result in accumulator. Example: XRI 39H
1011 0011=B3H 0011 1001=39H BEFORE EXECUTION 1000 1010=8AH AFTER EXECUTION
C Y A B3
A C
C Y A
0 8A
A C
ORA Register
OR specified register with accumulator (A). Store the result in accumulator. Example: ORA B
1010 1010=AAH 0001 0010=12H BEFORE EXECUTION 1011 1010=BAH AFTER EXECUTION
C Y
A C
C Y
A C
ORA B A=A or R
A B D H AA 12 C E L A B D H BA 12 C E L
ORA M
OR specified register with accumulator (A). Store the result in accumulator. Example: ORA M
0101 0101=55H 1011 0011=B3H BEFORE EXECUTION 1111 0111=F7H AFTER EXECUTION
C Y
A C
C Y
A C
A H
55 20 L
2050H
50
B3
ORA M A=A or M
A H
F7 20 L
B3 2050H 50
OR 8-bit data with accumulator (A). Store the result in accumulator. Example: ORI 08H
1011 0011=B3H 0000 1000=08H BEFORE EXECUTION 1011 1011=BBH AFTER EXECUTION
C Y A B3
A C
C Y A
0 BB
A C
Compare specified data in register or memory with accumulator (A). Store the result in accumulator. Example: CMP D or CMP M
BEFORE EXECUTION C Y A B D H H B8 10 B9 C E L L Z
AFTER EXECUTION C Y A B D H B9 0 Z B8 C E L 0
CMP D A-R
BEFORE EXECUTION
C Y A H B8
Z 2050 H 50 B8
AFTER EXECUTION
C Y A H
0 Z B8 20 L
1 2050 H 50 B8
20 L
CMP M A-M
BEFORE EXECUTION
AFTER EXECUTION
C Y A BA
C Y A
0 BA
A C
STC
BEFORE EXECUTION
AFTER EXECUTION
CY
STC CY=1
CY
CMC
BEFORE EXECUTION
AFTER EXECUTION
CY
CMC
CY
CMA
RLC
Rotate accumulator left Each binary bit of the accumulator is rotated left by one position. Bit D7 is placed in the position of D0 as well as in the Carry flag. CY is modified according to bit D7. Example: RLC.
BEFORE EXECUTION
CY
B7
B6
B5
B4
B3
B2
B1
B0
AFTER EXECUTION
B7
B6
B5
B4
B3
B2
B1
B0
B7
RRC
Rotate accumulator right Each binary bit of the accumulator is rotated right by one position. Bit D0 is placed in the position of D7 as well as in the Carry flag. CY is modified according to bit D0. Example: RRC.
BEFORE EXECUTION
B7
B6
B5
B4
B3
B2
B1
B0
CY
AFTER EXECUTION
B0
B7
B6
B5
B4
B3
B2
B1
B0
RAL
Rotate accumulator left through carry Each binary bit of the accumulator is rotated left by one position through the Carry flag. Bit D7 is placed in the Carry flag, and the Carry flag is placed in the least significant position D0. CY is modified according to bit D7. Example: RAL.
BEFORE EXECUTION
CY
B7
B6
B5
B4
B3
B2
B1
B0
AFTER EXECUTION
B7
B6
B5
B4
B3
B2
B1
B0
CY
BEFORE EXECUTION
B7
B6
B5
B4
B3
B2
B1
B0
CY
AFTER EXECUTION
CY
B7
B6
B5
B4
B3
B2
B1
B0
Concept of Subroutine
In 8085 microprocessor a subroutine is a separate program written aside from main program ,this program is basically the program which requires to be executed several times in the main program. The microprocessor can call subroutine any time using CALL instruction. after the subroutine is executed the subroutine hands over the program to main program using RET instruction.
Branching Instructions
The branch group instructions allows the microprocessor to change the sequence of program either conditionally or under certain test conditions. The group includes, (1) Jump instructions, (2) Call and Return instructions, (3) Restart instructions,
PC
Jump unconditionally to the address. The instruction loads the PC with the address given within the instruction and resumes the program execution from specified location. Example: JMP 200H
JMP 2000H
PC
2000
Conditional Jumps
Instruction Code JC JNC JP JM JPE JPO JZ JNZ Decription Jump on carry Jump on not carry Jump on positive Jump on minus Jump on parity even Jump on parity odd Jump on zero Jump on not zero Condition For Jump CY=1 CY=0 S=0 S=1 P=1 P=0 Z=1 Z=0
CALL address
Call unconditionally a subroutine whose starting address given within the instruction and used to transfer program control to a subprogram or subroutine. Example: CALL 2000H
Conditional Calls
Instruction Code CC CNC CP CM CPE CPO CZ CNZ Description Call on carry Call on not carry Call on positive Call on minus Call on parity even Call on parity odd Call on zero Call on not zero Condition for CALL CY=1 CY=0 S=0 S=1 P=1 P=0 Z=1 Z=0
RET
Return from the subroutine unconditionally. This instruction takes return address from the stack and loads the program counter with this address. Example: RET
BEFORE EXECUTION
AFTER EXECUTIO
SP PC
27F D
SP PC
27F F 620 0
RE T
RST n
Restart n (0 to 7) This instruction transfers the program control to a specific memory address. The processor multiplies the RST number by 8 to calculate the vector address. Example: RST 6
BEFORE EXECUTION
AFTER EXECUTIO
SP-1
SP PC 300 0 200 0 2FFEH 2FFFH 3000H SP PC 299 9 003 0 01 2FFEH 20 2FFFH 3000H
RST 6
No operation No operation is performed. The instruction is fetched and decoded but no operation is executed. Example: NOP
RIM INSTRUCTION
SIM
Set Interrupt Mask This is a multipurpose instruction and used to implement the 8085 interrupts 7.5, 6.5, 5.5, and serial data output. The instruction interprets the accumulator contents as follows. Example: SIM
SIM Instruction