Instruction set and working of microprocessor 8085
Instruction set and working of microprocessor 8085
b+c
Basic points
8085 instruction is called a mnemonic
A mnemonic is made up of opcode
(operation code)and operand (A-C)
Opcode is the code which is going to work
Operand is data on which the code is going
to work.
Instruction are written in hex system
In the instruction address[ML] is written as
lower byte , higher byte.
ADDRESSING MODES IN 8085
The term addressing modes refers to the
way in which the operand of an instruction
is specified. OR Addressing mode is the
way of addressing a memory location in
instruction.
Types of addressing modes
Direct addressing mode
Register addressing mode
Register indirect addressing mode
Immediate addressing mode
Implicit/implied addressing mode
Direct addressing mode
39 BCD 0 0 1 1 1 0 0 1
12 BCD 0 0 0 1 0 0 1 0
+(51) BCD 0 1 0 0 1 0 1 1
4 B
DAA(Decimal Adjust Acc)
The binary sum is 4BH .but BCD Sum is
51H.
To adjust result add 6 to lower nibble
4B 0 1 0 0 1 0 1 1
06 0 0 0 0 0 1 1 0
51 0 1 0 1 0 0 0 1
Logical Group
AND
X Y Z(X.Y)
1 1 1
1 0 0
0 1 0
0 0 0
OR
X Y Z(X+Y)
1 1 1
1 0 1
0 1 1
0 0 0
Logical Group
ANA r[logical and with Acc]
The content of Acc are logically ANDed with
the content of register r.
Result is placed in Acc.
S,Z and P flags are modified.
The CY flag is reset and AC flag is set.
E.g. let [A]=25H and [B]=31H
Instruction :ANA B
A 25H 0 0 1 0 0 1 0 1
B 31H 0 0 1 1 0 0 0 1
AND 0 0 1 0 0 0 0 1
After execution
AND 0 0 1 0 1 0 0 1
0 0 0
0 1 1
1 0 1
1 1 0
Logical Group
XRA r[Exclusive OR with Acc]
The contents of Acc are logically exclusive –
ORed with the contents of register r.
The result is placed in Acc.
The r may be any one of the A,B,C,D,E,H,and L
register.
S,Z,P are modified and CY and AC flags
are reset.
Let [A]=25H and [B]=39H
A 25 0 0 1 0 0 1 0 1
Instruction XRA
B B
39 0 0 1 1 1 0 0 1
After execution
OR 0 0 0 1 1 1 0 0
A>B 0 0
A=B 1 0
A<B 0 1
CMP R
A&R
CMP B
A=12H,B=20H
ACC
ABN
CY1
A=25H B=20H
ACC
ABN
Z AND CY0
A=15H B=15H
ACC
ABN
Z1
Logical Group
E.g. Let[A] =15H and [H]=57H
Instruction CMP H
After execution CY=1, Z=0.
Conclusion Zero Flag ‘Z’ Carry Flag ‘CY’
A>B(ABN) 0 0
A=B 1 0
A<B(ACC) 0 1
Logical Group
CMP M[Compare Memory with Acc]
This instruction compares the content of
memory location whose address is stored in
HL pair with the content of Acc by
subtracting the content of memory location
from the content of Acc.
The content of Acc remains unchanged.
If [A]<[M] then CY flag is set to 1.
If [A]=[M] then Z flag is set to 1.
If [A]>[M] then
Conclusion
Z and
Zero Flag ‘Z’
CY flags are reset
Carry Flag ‘CY’
A>M(ABN) 0 0
A=M 1 0
A<M(ACC) 0 1
Logical Group
* CPI 8 bit-data[Compare immediate with
Acc]
STC [Set the Carry flag]
CY1
Only carry flag is affected.
CMC [Complements the Carry flag]
[CY][CY]
Only carry flag is affected.
CMA[Complements the Acc]
A 1’s complement of A.
No flag is affected.
Rotate Instruction
RLC [Rotate Acc left]
The contents of Acc are rotated left by 1.
The contents of Acc are rotated to left by 1
bit position.
The bit
CY
A7A7is stored
A6 A5
in A4bit A0
A3
as
A2
well
A1
asA0 in
carry flag.
Rotate Instruction
RLC
E.g. Let [A]=45H and [CY]=0
Instruction RLC
Before execution
cy A7 A6 A5 A4 A3 A2 A1 A0
0 0 1 0 0 0 1 0 1
After execution
Cy A7 A6 A5 A4 A3 A2 A1 A0
0 1 0 0 0 1 0 1 0
Rotate Instruction
RLC
Thus [A]=27H and CY=1
Only CY flag is affected.
RRC[ Rotate Acc Right]
The contents of Acc are rotated right by 1.
The contents of Acc are rotated right by
one bit position. The bit A0 of Acc is stored
in the bit A7 as well as in carry flag.
The LSB goes to the Carry and the MSB.
Carry flag is affected.
CY A7 A6 A5 A4 A3 A2 A1 A0
Rotate Instruction
E.g. let [A]=83 and [CY]=0
Instruction RRC
Before executioncy A7 A6 A5 A4 A3 A2 A1 A0
0 1 0 0 0 0 0 1 1
After execution
Cy A7 A6 A5 A4 A3 A2 A1 A0
1 1 1 0 0 0 0 0 1
Cy A7 A6 A5 A4 A3 A2 A1 A0
1 0 1 0 1 0 1 0 1
Inst RAL
After execution
Cy A7 A6 A5 A4 A3 A2 A1 A0
0 1 0 1 0 1 0 1 1
Instruction RAR
After execution
cy A7 A6 A5 A4 A3 A2 A1 A0
1 0 0 0 1 1 1 0 1
stackD014 20 D014 20
D015
SP D015
SP
Machine control group
(Stack Operation)
POP rp[ POP off Stack to register pair]
[rl][SP]
[rh][SP]+1
[SP][SP]+2
The contents of the memory location , whose address is
specified by the stack pointer are moved to low order
register of register pair rp.
The contents of the memory location , whose address is
one more than the content of stack pointer are moved
to high order register of register pair.
The SP is incremented by 2.
E.g. Let [SP]=2001H
Instruction : POPH
Machine control group
(Stack Operation)
Before execution stack After
2001 10
execution stack
2001 10
2002 20
SP 2002 20
2003
2003
SP
1
Machine control group
(Stack Operation)
XTHL[Exchange H and L with top of stack]
[L][SP]
[H][SP]+1
The contents of the L register are exchanged with the content of
the location , whose address is stored in SP.
The content of H register are exchanged with the next location.
Contents of SP are not altered.
E.g. let[H]=20H [L]=FFH
Instruction XTHL
Before execution After execution
SP FF SP
[L]
AB [L]
20 [H]
CD [H]
Other instructions(I/O)
IN port[Input 8 bit data from an input port
to Acc]
A data
E.g. IN 10H
This instruction is used to read data from an I/O
port , whose address is given in the instruction.
This data can be read into the Acc only.
ANI ACH
Instruction ANI ACH
After execution 8 4 2 1 8 4 2 1
A56H 0 1 0 1 0 1 1 0
ACH 1 0 1 0 1 1 0 0
AND 0 0 0 0 0 1 0 0
Result [A]=04H
INR A
Instruction INR A
After execution
8 4 2 1 8 4 2 1
A56H 0 1 0 1 0 1 1 0
+1 0 0 0 0 0 0 0 1
Result A=57H
AND 0 1 0 1 0 1 1 1
H 5 7
CLASSWORK
1) The Acc of 8085 contains data 43H. What will be
its contents after the execution following
instructions independently?
A) CMA B)ANI 09H C)INR A
2) The Acc of 8085 microprocessor contains the
data 45H and register E contains the data 7BH.
What will be the content of Acc after execution of
each of following instruction independently.
A) XRA E B) ADI C5H C)ORI 5BH
3) Acc contains data 2AH. What will be content of
Acc after execution of each instruction
independently.
A) CMA B)ANI 05H C)STC
4) Acc contains 45H , register E contains 3BH . Write
the contents of Acc after execution of following
instructions independently.
1) SUB E 2)XRA E 3) RRC 4) MOV E,A
5) If Acc contains data BCH , register C contains ADH
. What will be the content of Acc after execution of
each of the following instruction independently.
1) SUB C 2)CMA 3)XRA C
6) The Acc contains the data A4H. What will be its
contents after execution of following instructions
independently.
1) XRI 08H 2)CMA 3)SUB A
8085 Microprocessor
Code
OPCODE OPERAND
C030 06 C030 06
C031 07 C031 07
C032 00 C032 0D
8085 Microprocessor Code
OPCODE OPERAND
C000
C001
. LXI H,C030H 21
30
Initialize Hl As Memory Pointer
C00C 01
MEMORY DATA
MEMORY DATA LOCATION
LOCATION
C030 06
C030 06
C031 0A C031 07
C032 00 C032 04