8_Bit_add_Carry
8_Bit_add_Carry
Algorithm:
Step 8 : Get the address of the memory location in HL pair to store Sum.
Step 10: Get the address of the memory location in HL pair to store Carry.
Initialize Reg.
B with 00H
Is
there any
Carry?
Increment
Carry
Store Sum
Store Carry
End
Program:
Address Machine Label Mnemon Operands Comment
Codes ics
2000 06 MVI B, 00 Initialize Reg B with 00H for carry.
2001 00
2002 21 LXI H, 2500H Initialize HL pair with the address of 1st
2003 00 number.
2004 25
2005 7E MOV A,M Move the first number into Accumulator
2006 23 INX H Increment HL pair for address of 2nd No/.
2007 86 ADD M Add the numbers
2008 D2 JNC AHEAD Jump if carry doesn’t exist
2009 0C
200A 20
200B 04 INR B Increment carry.
200C 23 AHEAD INX H Increment HL pair for address of next
location.
200D 77 MOV M,A Save Sum in memory
200E 23 INX H Increment HL pair for address of next
location.
200F 70 MOV M,B Save Carry in memory
2010 76 HLT Halt.