Addition of 8-bit Numbers in 8085

This post would present you with assembly language program for 8-bit addition in 8085 microprocessor. We will consider 2 different cases of addition

(i) Addition of two 8-bit numbers generating no carry

(ii) Addition of two 8-bit numbers generating a carry

Addition of two 8-bit numbers generating no carry

// Manually store 1st number in the memory location 2000H
// For Example 1st number = 18H; i.e, 2000<-18H
// Manually store 2nd number in the memory location 2001H
// For Example 2nd number = 29H; i.e, 2001<-29H
// Store the result in the memory location 2003H
// For this Example result will be 18H + 29H = 41H

#BEGIN 0000H     // Program counter will be loaded with 0000H
LDA 2000H        // A<-18H
MOV B,A          // B<-18H
LDA 2001H        // A<-29H
ADD B            // A<-A+B; A<-41H
STA 2003H        // 2003<-41H
HLT              // Stop the Program

#ORG 2000H       // Loads the DB values starting from this address
#DB 18H,29H

Note: If you find any error wile assembling the above code then just remove the comment lines written right to the code lines.

Following are the screenshots after assembling the above Hex code” and the memory content after simulating the code”.

8-bit addition assembler

Assembled Code

8-bit addition Memory Editor

Memory Content

Note: The code has been assembled and simulated on Jubin’s 8085 Simulator

Addition of two 8-bit numbers generating a carry

The following Hex Code is applicable for no carry generation also. This program is a generic one for both no-carry and carry generation situation.

// Manually store 1st number in the memory location 2000H
// For Example 1st number = A9H; i.e, 2000<-A9H
// Manually store 2nd number in the memory location 2001H
// For Example 2nd number = B8H; i.e, 2001<-B8H
// Store the result in the memory location 2002H
// Store the carry in the memory location 2003H
// For this Example result will be A9H + B8H = 161H
// 2003<-01H, 2002<-61H

#BEGIN 0000H     // Program counter will be loaded with 0000H
LDA 2000H        // A<-A9H
MOV B,A          // B<-A9H
LDA 2001H        // A<B89H
MVI C,00H        // Clear the Register C
ADD B            // A<-A+B; A<-61H
JNC LABEL        // Jump to the position LABEL
INR C            // C<-01H

LABEL: STA 2002H // 2002H<-61H
       MOV A,C   // A<-C
       STA 2003H // 2003<-01H
HLT              // Stop the Program

#ORG 2000H       // Loads the DB values starting from this address
#DB A9H,B8H



Leave a Reply

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