Addition and Subtraction of two 32 bit nos.

Addition and Subtraction of two 32 bit nos.

1.Addition
LXI B,9000H
LXI H,C200H
LXI D,9500H  //RESULT
MVI A,04H
STA A000H
XRA A
LDAX B //LOOP
ADD M
STAX D
INX B
INX H
INX D
LDA A000H
DCR A
STA A000H
JNZ UP
RST




2. SUBSTRACTION
LXI B,9000H
LXI H,C200H
LXI D,9500H  //RESULT
MVI A,04H
STA A000H
XRA A
LDAX B //LOOP
SBB M
STAX D
INX B
INX H
INX D
LDA A000H
DCR A
STA A000H
JNZ UP
RST

OUTPUT :-
take the values: 1035C2A0   //d200
                        +B7407862   //c200
                        =C7833B62  //result

Go to d200 memory location & store data like this -
          A0
          C2
          35
          10

then  C200
          62
          78
          40
          B7

Result A000 
           62 
           3B
           83 
           C7

No comments:

Post a Comment