Addition of 16-bit Numbers in 8085

This post would present you with assembly language program for 16-bit addition in 8085 microprocessor. The following Hex Code is a generic one for both no-carry and carry generation situation.

// Manually store 1st 16-bit number in the memory location 2000H & 2001H in reverse order
// For Example 1st number = B349H; i.e, 2000<-49H & 2001H<-B3H
// Manually store 2nd 16-bit number in the memory location 2002H & 2003H in reverse order
// For Example 2nd number = 81B6H; i.e, 2002<-B6H & 2003<-81H
// Store the result in the memory location 2004H, 2005H
// Store the carry in the memory location 2006H
// For this Example result will be B349H + 81B6H = 134FFH
// 2004<-FFH, 2005<-34H, 2006<-01H

#BEGIN 0000H       // Program counter will be loaded with 0000H
LHLD 2000H         // L<-49H, H<-B3H; HL=B349H
XCHG               // DE<-HL; DE = B349H
LHLD 2002H         // L<-B6H, H<-81H
MVI C,00H          // Clear the Register C
DAD D              // HL<-HL+DE; HL<-34FFH
JNC LABEL          // Jump to the position LABEL
INR C              // C<-01H

LABEL: SHLD 2004H  // 2004H<-FFH, 2005H<-34H
       MOV A,C     // A<-C
       STA 2006H   // 2006<-01H
HLT                // Stop the Program

#ORG 2000H         // Loads the DB values starting from this address
#DB 49H,B3H,B6H,81H



Memory Location

Input

2000     2001     2002     2003

49         B3        B6         81

Output

2004     2005     2006

FF        34         01

Note: The above Hex code has been assembled and simulated on Jubin’s 8085 Simulator. If you find any error wile assembling the above code then just remove the comment lines written right to the code lines.

1 comment for “Addition of 16-bit Numbers in 8085

Leave a Reply

Your email address will not be published. Required fields are marked *