SUB



Syntax: SUB R
Where R can be any of the general purpose registers (A,B,C,D,E,H andL)
Byte: 1byte
Addressing Mode: Register Addressing

Working: 
1. 
2. 
3. 
4. Flag

Example: SUB B 
where [B] = 11H 
and [A]= 22H
After execution of SUB B
[A] = 11H 
[B] = 22H

Program: write an ALP for 8bit subtraction  of values present in Registers A and B where A carries 44H and B carries 30H. Store result at memory location 5000H.

Label  Mnemonics  Comments
Start: SUB B 
          STA 5000H 
 Stop: HLT

Output: [5000H]= 14H



LXI H, 4000H ; 4000= 90h
MOV A,M ; a= 90h
INX H ; 4001h where 4001= 40h
MOV B, M ; b= 40h
SUB B ; a= a - b ... A = 90 - 40= 50h
INX H ; 4002h
MOV M,A ; 4002h = 50h
HLT
           

Comments

Popular posts from this blog

XRI