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

Addition of 2 - 16 - Bit Nos.

The document outlines an algorithm for adding two 16-bit numbers with carry, detailing initialization, loading numbers, performing addition, checking for carry, and storing results. It includes a flow chart illustrating the process and a program with machine codes and comments for implementation. The program is structured to handle carry and store both the sum and carry in memory before halting.
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)
13 views3 pages

Addition of 2 - 16 - Bit Nos.

The document outlines an algorithm for adding two 16-bit numbers with carry, detailing initialization, loading numbers, performing addition, checking for carry, and storing results. It includes a flow chart illustrating the process and a program with machine codes and comments for implementation. The program is structured to handle carry and store both the sum and carry in memory before halting.
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 16-bit Numbers with Carry

Algorithm:

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

Step 2 : Load the first 16 bit number into HL pair

Step 3 : Move the first 16 bit number into DE pair.

Step 4 : Load the second 16 bit 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 : Store Sum in memory

Step 9 : Store Carry in memory.

Step 10: Halt.


Flow Chart:

Start

Initialize Reg B with 00H


for Carry

Load the HL pair with


the first 16 bit number

Move the first 16 bit


number into DE 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, 00H Initialize Reg B with 00H for Carry
2001 00
2002 2A LHLD 2500H Get 1st 16 bit number into HL pair
2003 00
2004 25
2005 EB XCHG Get 1st 16 bit number into DE pair from
HL pair
2006 2A LHLD 2502H Get 2nd 16 bit number into HL pair
2007 02
2008 25
2009 19 DAD D Add the two numbers
200A D2 JNC AHEAD Jump if carry doesn’t exist
200B 0E
200C 20
200D 04 INR B Increment carry.
200E 22 AHEAD SHLD 2504 Store Sum in memory
200F 04
2010 25
2011 78 MOV A, B Move carry into Accumulator
2012 32 STA 2506 Store Carry
2013 06
2014 25
2015 76 HLT Halt

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy