CA Address
CA Address
The instruction SHLD 5648 H will copy the contents of register L (79 H) to
memory location 5648 H and the contents of register H (43 H) to memory location
5649 H.
10. LHLD Address [L+ (Address), H- (Address + 1)]
This instruction copies the contents of memory location specified in instruction to
the registers H and L.
The contents of the memory location specified in the instruction are copied into
the L register and the contents of the next memory location are copied to the H
register.
Example : LHLD 5648 H
Let H=43 H,L=79 H, the contents of memory locations 5648 H and 5649 Hare
10H and 50H.
The instruction LHLD 5648 Hwill copy the contents of memory location 5648 H
(10H) to the register L and the contents of memory location 5649 H(50 H) to the
register H.
11. STAX Rp (Rp )- AJ
This instruction copies the contents of .accumulator to memory location whose
address is pointed by the specified register pair.
The register R, can be a valid register pair like BC or DE only.
The contents of the accumulator remain unchanged.
Example: STAX D:
Let A=29 H, D=57 H, E= 48 H.
The instruction STAX D will copy the contents of accumulator (29 H) to the
memory location, whose address is given by DE register pair i.e. 5748 H.
12. LDAX R [A+ (R)]
This instruction copies the contents of memory location whose address is pointed
by the specified register pair to the accumulator.
The register R, can be any valid register pair like BC or DE only.
The contents of the memory location remain unchanged.
Example : LDAX D:
Let A = 29 H, D = 57 H, E = 48 H.
The instruction LDAX D will copy the contents of the memory location, whose
address is given by DE register pair i.e. 5748 H(10 H) to the accumulator.
13. XCHG [H + D, L + E]
Example:XCHG
Let H= 12 H, L= 11 H, D= 57 H, E= 23 H
Computer Architecture (PTU) 3-38 Microprocessor 8085
The instruction XCHG exchanges the contents of register pair HL with the
contents of register pair DE.
3.17.3 Arithmetic Group Instructions :
This group of instructions pcrform arihmctic opcrations such as addition, subtraction,
increment and decrement :
Addition
Any 8-bit number, or the contents of a register or the contents of a
memory location can be added to the contents of the accumulator
and the sum is stored in the accumulator. No two other 8-bit
registers can be added directly (e.g., the contents of register B
cannot be added directlyto the contents of the register C).
Subtraction Any 8-bit number, or the contents of a register, or the contents of a
memory location can be subtracted fromn the contents of the
accumulator and the results stored in the accumulator. The
subtraction is performed in 2's complement, and the results if
negative, are expressed in 2's complement. No two other registers
can be subtracted directly.
Increment/Decrement The 8-bit contents of a register or a memory location can be
incremented or decrement by 1. Similarly, the 16-bit contents of a
register pair (such as BC) can be incremented or decrement by 1.
These increment and decrement operations differ from addition and
sublraction in an important way; i.e., they can be performed in any
one of the registersor in a memory location.
The arithmetic group of instructions include following instructions :
1. ADD R 2. ADD M 3. ADC R 4. ADC M
5. ADI data 6. ACI data 7. DAD R 8. SUB R
9. SUB 10, SBB R 11. SBB M 12. SUl data
13. SBI data 14. DAA 15, INRR 16. INR M
17. DCR R 18. DCR M 19. | INX Rp 20. DCX Rp
14. ADD R [A-A+R]
This instruction adds the contents of register R with the
contents of he
accumulator. The result of addition is stored in the accumulator.
The register R can be any general purpose registers such as A, B, C, D, E,
L.
H and
Example : ADD C
A+C- A.
Computer Architecture (PTU) 3-39 Microprocessor 8085
Let A=50 H, C= 20 H.
The instruction ADD Cwill add the contents of register C (20 H) with
the
contents of the accumulator i.e.50 H. The result of addition (70 H) will be stored
in the accumulator.
15. ADD M (A-A+ (HL))
This instruction adds the contents of memory location pointed by the HL register
pair with the contents to accumulator. The result is stored in accumulator.
Example:ADD M
A+ M ’ A.
Let A=50 H, H= 24 H, L=56 H, contents of memory location 2456 H= 40H.
The instruction ADD M will add the contents of memory location 2456 H
1.e. (40H) with the contents of the accumulator ie.50 H. The result of addition
(90 H) will be stored in the accumulator.
16. ADI Data [A+A +Data (8 bit)]
This instruction adds the 8 bit data specified along with the contents of the
accumulator. The result is stored in accumulator.
Example :ADI 40 H
This instruction adds the immediate data (40 H) to contents of the accumulator.
The result is in accumulator.
17. ADC R [A+A+R+ CY]
This instruction adds the contents of register R along with the carry to the contents
of the accumulator. The result of addition is stored in the accumulator.
The register R can be any general purpose registers such as A, B, C, D, E, H
and L.
Example: ADC C
A+C+ CY ’ A.
Let A=50H, C =20 H and CY = 1.
The instruction ADC Cwill add the contents of register C(20 H) and contents of
carry (01 H) with the contents of the accumulator i.e.50 H. The result of addition
(71 H) will be stored in the accumulator.
18. ADC M [A + A+ (HL) + CY]
This instruction adds the contents of nemory location pointed by the HL register
pair and the contents of carry with the contents to accunulator. The result is
stored in accumulator.
Computer Architecture (PTU) 3-40
MicroproCeSSor 8085
Example: ADC M
A+ M + CY ’ A.
Let A= 50 H, H= 24 H, L = 56 H, contents of memory location 2456 He An
and the Contents of carry = 1.
The instruction ADC M will add the contents of memory location 2456 u
i.e. (40H) and carry along with the contents of the accumulator i.e.50 H Tha
result of addition (91 H) will be stored in the accumulator.
19. ACI Data [A+A+ Data (8 bit) +CY]
This instruction adds the 8 bit data specified and contents of carry along with the
contents of the accumulator. The result is stored in accumulator.
Example: ACI 40H
This instruction adds the immediate data (40 H) and carry (01 H) to contents of
the accumulator. The result is stored in the accumulator.
20. DAD Rp [HL 4 HL + Rp]
This instruction adds the contents of specified register pair to HL pair and stores
the result in HL pair.
The register pair R, can be SP, BC, DE or HL.
Example : DAD B:BC + HL ’HL.
Let BC =5023 H, HL = 1234 H then the instruction DAD B will add the contents
of register pair BC (5023 H) with the contents of register pair HL (1234 H) and
the result of addition 6257 H is stored in the HL
register pair.
21. SUB R [A+A-R]
This instruction subtracts the contents of register R from the contents of us
accumulator. The result of subtraction is stored in the accumulator.
The register R can be any general purpose registers such as A, B, C, D, E, Ha
L.
Example : SUB C
A-C’ A.
Let A=50 H, C= 20 H.
The instruction SUB C will subtract the contents of register C (20 H) from the
contents of the accumulator i.e.50 H. The result of subtraction (30 H) willbe
stored in the accumulator.
22. SUB M
[A+A-(HL)]
This instruction subtracts the contents of memory location pointed by the HL
register pair from the contents to accumulator. The result is stored in accumulator.
3-41 Microprocessor 8085
Computer Architecture (PTU)
Example: SUB M
AM’A.
Let A =50 H, H = 24 H, L= 56 H, contents of memory location 2456 H=40 H.
The instruction SUB M will subtract the contents of memory location 2456 H
i.e. (40 H) with the contents of the accumulator i.e.50 H. The result of subtraction
(10 H) willbe stored in the accumulator.
23. SUI Data [A= A-Data (8 bit)]
This instruction subtracts the 8 bit data specified from the contents of the
accumulator. The result is stored in accumulator.
Example: SUI 4OH
This instruction subtracts the immediate data (40 H) from the contents of the
accumulator. The result is in accumulator.
24. SBB R [A+A-R-CY]
This instruction subtracts the contents of register R along with the carry from the
contents of the accumulator. The result of subtraction is stored in the accumulator.
The register R can be any general purpose registers such as A, B, C, D, E. H and
L.
Example: SBB C
AC-CY ’A.
Let A = 50 H,C = 20 H and CY = 1.
The instruction SBB Cwill subtract the contents of register C (20 H) and contents
of carry (01 H) from the contents of the accumulator i.e.50 H. The result of
subtraction (2F H) will be stored in the accumulator.
25. SBB M (A+A-(HL) CY]
This instruction subtracts the contents of memory location pointed by the HL
register pair and the contents of carry from the contents to accumulator. The result
is stored in accumulator.
Example: SBB M
A- M -CY ’ A.
9 3
A = 93 H BCD
RST N
JM JUMP on minus SF = 1
JC JUMP if carry CF = 1
Example: JZ C200
Let ZF =1.
This istruction will cause a JUMP to an address C200 H. ie. program counter
will load with C200 H as ZF =1,
Example ANI20 H
Let the contents of register A = FO H. The immediate data contents (20 H) are
ANDed with the contents of the accumulator. The result is stored in the
accumulator.
44. XRA R: [A+A XOR R]
The contents of the specified register are logically EX-ORed with the contents of
accumulator. The result is stored in accumulator.
The operation of EX-ORing is performed bit by bit i.e. D, bit of accumulator is
EX-ORed with bit D, of register and so on up to D, bit of accumulator EX-ORed
with D, bit of register.
Rcan be any general purpose registers such as A, B, C, D, E, Hand L.
Example XRA B.
Let the contents of register A = FO H and contents of register B = 20 H.The
contents of register B are EX-ORed with the contents of the accumulator. The
result is stored in the accumulator.
45. XRA M : [A+-A XOR (HL)]
The contents of the memory location pointed by the HL register pair are logically
EX-ORed with the contents of accumulator. The result is stored in accumulator.
The operation of EX-ORing is performed bit by bit i.e. Do bit of accumulator is
EX-ORed with bit D,of memory and so on up to D, bit of accumulator EX-ORed
with D, bit of memory.
Example: XRA M.
Let A = FO H, H= 57 H, L = 48 H and contents of memory location 5748 H = 20
H. The contents of memory location 5748 H are EX-ORed with the contents of
the accumulator. The result is stored in the accumulator.
46. XRIData: [A +AXOR Data]
The contents of the 8bit data specified in the instruction are logicallyEX-0Red
with the contents of accumulator. The result is stored in accumulator.
The operation of EX-ORing is performed bit by bit i.e. D, bit of accumulator is
EX-ORed with bit Do of data and so on up to D, bit of accumulator EX-ORed with
D, bit of data.
Example XRI 20 H
Let the contents of register A = FO H .The inmediate data contents (20 H) are
EX-ORed with the contents of the accumulator. The result is stored in the
accumulator.
Computer Architecture (PTU) 3-50 Microprocessor 8085
47. ORA R: [A+A v R]
The contents of the specified register are logically ORed with the contents of
accumulator. The result is stored in accumulator.
The operation of ORing is performed bit by bit i.e. D, bit of accumulator is ORed
with bit Do of register and so on up to D, bit of accumulator ORed with D, bit of
register.
R can be any gencral purpose registers such as A, B, C, D, E, H and L.
Example ORA B
Let the contents of register A =FO H and contents of register B = 20 H The
ContentsS of register B are ORed with the contents of the accumulator. The result is
stored in the accumulator.
48. ORA M: [A -Av (HL)]
The contents of the memory location pointed by the HL register pair are logically
ORed with the contents of accumulator. The result is stored in accumulator.
The operation of ORing is performed bit by bit i.e. D, bit of accumulator is ORed
with bit Do of register and so on up to D, bit of accumulator ORed with D, bit of
register.
Example ANA M
Let A = FO H, H= 57 H, L=48 H and contents of memory location 5748 H = 20
H. The contents of memory location 5748 Hare ORed with the contents of the
accumulator. The result is stored in the accumulator.
50. CMP R:
Operation:
This instruction connpares the contents of accumulator with the contents
register specified in the instruction. The conmparison is done by subtracting
of
contents of the register from the contents of the accumulator. The ressult
subtraction is discarded.
Computer Architecture (PTU) 3-51 Microprocessor 8085
Compare CF ZF
A>R 0
A<R 1
A=R 0 1
Example CMP B
Let A = 29 H, B = 43 H.
Then the instruction CMP B will result with carry flag set as the contents of the
accumulator are less than the contents of register B.
51. CMP M :
Operation :
This instruction compares the contents of accumulator with the contents of
memory location specified by the HL register pair. The comparison is done by
subtracting the contents of the memory location from the contents of the
accumulator. The result of subtraction is discarded.
The result is not stored in either of the memory location or accumulator. The
accumulator and register remain unchanged, only tlags are updated
If the contents of accumulator are cqual to the contents of the memory location
then the zero flag is set. If the contents of accumulator are less than the contents
of the memory location then the carry tlag is set. If the contents ot accumulalor
are more than the contents of the menory location then the carry tlag and the zero
flag are reset.
Note The compare instructions are often used with conditional Jump instructions.
Compare CF Z
A> M 0 0
A< M
A= M
Microprocessor 808s
3-52
Computer Architecture (PTU)
CMP M memory location 5748 H=15 H.
Example of
H=57 H, L=48 H, contents contents of theaccumulator are more
Let A = 29 H, carry flag reset as
the
will result with ofregister B.
Then the instruction CMP M than the contents
52. CPI Data :
sets the conditinn
Operation immediate data with accumulator and
compares
This instruction
subtraction.
flags as a result of the
contents are not altered.
The accumulator Jump instructions
used with conditional
Note The compare instructions are often
CF ZF
Compare
A> M 0
A<M 1 0
A= M 1
Example CPIFO H
Let A = OFO H
flag reset as the contents of the
Then the instruction CPI FOH will result with zero
accumulator are equal to the contents of register B.
53. STC :
Operation This instruction sets the carry flag.
Before execution After execution
SF ZF U AF PF CF SF ZF AF PF U CF
Carry is set.
Fig.3.15
54. CMC :
Operation CY= CY
This instruction inverts the value of carry flag.
Before execution After execution
SF ZF U AF PF CF SF ZF U AF PF U CF
1
Carry is complemented
Fig. 3.16
Computer Architecture (PTU) 3-53 Microprocessor 8085
CMA:
55.
Operation : A= A
56. RLC:
Fig. 3.17
57. RRC :
CF MSB ’ LSB
Operation
This instruction rotates all the bits of the accumulator by 1bit position to the right.
The bit moved out of the LSB is rotated around into the MSB.
The data bit moved out of LSB is also copied into CF.
Bit Bo is placed in bit B, as well as in carry.
Example RRC
Let A = 1111 1110and CY= 1
Computer Architecture (PTU) 3-54
MicroprOcessor 8085
Before execution After execution
Fig. 3.18
58. RAL :
Fig. 3.20
Computer Architecture (PTU) 3-57 Mícroprocessor 8085
masked
I- interrupt is pending /
pending / masked
0- interrupt is not
logic Jer.l.
SID bit - specifies serial ip data. When RIM instruction is executed the
serial port.
Bit D, is status of
SID pin is copied at bitD,. interrupts. lf RST 7.5and RST5.5 innuto
of pending
Bits D, D, and D, are status RST 7.5. As the RST 5.5 is having Jecn
ISR of
occurs the 8085 will branch to interrupt. when RIM instruction is
RST 7.5 so it will be pending
priority then and RST 5.5 pending is copied at bits D6
executed the status of RST 7.5, RST 6.5
D, and D, respectively.
to D, are status of interrupt enable flip flop, mask 7.5, mask 6.5 and mask
Bits D,
5.5. When RIM instruction is executed the status of masking is
loaded at bits D., to
Do
Examples :
(a) RIM instruction is executed and accumulator bit pattern is 0010 0000. The bit
pattern indicates that RST 6.5 is pending interrupt.
(b) RIM instruction is executed and accumulator bit pattern is 0000 1010. The bit
pattern indicates interrupt enable flip flop is set, RST 6.5 is masked and RST 7.5
and RST 5.5 are unmasked.
70. SIM :
Serial port
control
Dy
Interrupt control logic
D6 Ds D4 D3 De
SOD SDE X D Do
R7.5 MSE M7.5
M6.5 M5.5
Serialoutput data <
’Mask RST 5.5
Serial data enable
1= Enable serial port ’Mask RST 6.5
0= Disable serial port +Mask RST 7.5
Don't care 1 = Mask or disable
O= Unmask or enable
1=
0= Reset
R
No effect7.5
on flip-flop
Mask set enable
R7.5 1=Masking is enabled
O= Masking is disabled
Fig. 3.23
Computer Architecture (PTU) 3-59 MicroproOcessor 8085
1 0 1