Add contents of two memory locations
Statement : Add the contents of memory locations 4001H and 4001H and place the result in the memory locations 4002H and 4003H.
Sample problem:
(4000H) = 7FH
(4001H) = 89H
Result = 7FH + 89H = 108H
(4002H) = 08H
(4003H) = 01H
Source program:
LXI H, 4000H : “HL Points 4000H”
MOV A, M : “Get first operand”
INX H : “HL Points 4001H”
ADD M : “Add second operand”
INX H : “HL Points 4002H”
MOV M, A : “Store the lower byte of result at 4002H”
MVI A, 00 : “Initialize higher bute result with 00H”
ADC A : “Add carry in the high byte result”
INX H : “HL Points 4003H”
MOV M, A : “Store the higher byte of result at 4003H”
HLT : “Terminate program execution”
Sample problem:
(4000H) = 7FH
(4001H) = 89H
Result = 7FH + 89H = 108H
(4002H) = 08H
(4003H) = 01H
Source program:
LXI H, 4000H : “HL Points 4000H”
MOV A, M : “Get first operand”
INX H : “HL Points 4001H”
ADD M : “Add second operand”
INX H : “HL Points 4002H”
MOV M, A : “Store the lower byte of result at 4002H”
MVI A, 00 : “Initialize higher bute result with 00H”
ADC A : “Add carry in the high byte result”
INX H : “HL Points 4003H”
MOV M, A : “Store the higher byte of result at 4003H”
HLT : “Terminate program execution”
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment