[go: up one dir, main page]

0% found this document useful (0 votes)
6 views3 pages

8_Bit_add_Carry

The document outlines an algorithm for adding two 8-bit numbers with carry, detailing steps from initializing registers to storing the sum and carry in memory. It includes a flowchart illustrating the process and a program with machine codes and comments for implementation. The program initializes registers, retrieves numbers, performs addition, checks for carry, and stores results accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

8_Bit_add_Carry

The document outlines an algorithm for adding two 8-bit numbers with carry, detailing steps from initializing registers to storing the sum and carry in memory. It includes a flowchart illustrating the process and a program with machine codes and comments for implementation. The program initializes registers, retrieves numbers, performs addition, checks for carry, and stores results accordingly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Addtion of Two 8-bit Numbers with Carry

Algorithm:

Step 1 : Intialize the Reg B for Carry. Initial value = 00H.

Step 2 : Initialize HL pair with the address of 1st number.

Step 3 : Get the first number into accumulator.

Step 4 : Get the address of 2nd number into HL pair.

Step 5 : Add the numbers.

Step 6 : Check for Carry. If carry doesn’t exist go to step No 8.

Step 7 : Increment the content of Reg B, when Carry exists.

Step 8 : Get the address of the memory location in HL pair to store Sum.

Step 9 : Store Sum in memory.

Step 10: Get the address of the memory location in HL pair to store Carry.

Step 11: Store Carry in memory.


Flow Chart:
Start

Initialize Reg.
B with 00H

Initialize HL pair with


address of first number.

Get 1st number


into Accumulator

Get the address of next


number into HL pair

Add the two


Numbers

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.

You might also like