Write an 8085 program to add two 16-bit hexa-decimal numbers - ChromeTechny
Home » Write an 8085 program to add two 16-bit hexa-decimal numbers

Write an 8085 program to add two 16-bit hexa-decimal numbers

So far in this 8085 programming series, we have only done calculation related to 8-bit hexadecimal and decimal numbers.

But in this post, we are going to learn how we can add two 16-bit hexadecimal numbers. Even though we cannot execute 32-bit number operations but we can perform the 16-bit operation.

For this 8085 program, we are going to use the concept of MSB (Most Significant Bit) and LSB (Least Significant Bit). As we are going to perform addition operation between two 16-bit hexadecimal numbers, we are going to use 4 memory location to store the LSB and MSB, two more memory location to store the result, and an additional one to store the carry.

For addition take small numbers that won’t produce carry, because if it does then we have to manage it. Don’t worry we are going to use a program that’s gonna handle the carry but if you want to make your programs shorter than it’s better to take small numbers.


Let the first 16-bit number be 34ACH, the ACH number will be stored at 2000H and the rest part i.e. 34H will be stored at memory location 2001H.

In a similar way, we are going to store the next 16-bit hexadecimal number 1E9BH in memory location 2002H and 2003H. We are also going to leave memory location 2005H, 2006H and 2007H to store the result and the carry.


LHLD 2000 // we are going to store the content of 200H and 2001H ML in HL
XCHG // using exchange instruction, we are going to copy the content to DE register pair
LHLD 2002 //again we are going to use LHLD instruction to copy the content of 2002H and 2003H ML to HL register pair
MVI C,00 //to adjust the carry we are going to take C register and make its content NULL
DAD D // using DAD instruction we are going to perform the addition instruction
JNC Label // JNC is used as a jump instruction, it will work only when no carry is generated
INR C //in case a carry is generated, we are going to increment the value of C register to 1
Label SHLD 2004 // using SHLD instruction, we will store the result in 2004H and 2005H memory location
MOV A, C //now to adjust the carry we copy the content of C reg in the accumulator
STA 2006//Lastly, using STA we store the content of accumulator in 2006H memory location

Programming Details
Memory Location OPCODE Operand Label Hex Code
2007 LHLD 2000H 2AH
2008 00H
2009 20H
200B LHLD 2002H 2AH
200C 02H
200D 20H
200E MVI C,00 OEH
200F 00H
2010 DAD D 19H
2011 JNC lablel D2H
2012 15H
2013 20H
2014 INR C 0CH
2015 SHLD 2004 label 22H
2016 15H
2017 20H
2018 MOV A,C 79H
2019 STA 2006 32H
201A 06H
201B 20H
201C HLT 76H

About the author


Hi there! this is Ayan. I am a part-time blogger, my blog is https://dreamtodeff.com/, on this site, I mostly focus on WWE, Tech news, and Programming

Add Comment

Click here to post a comment

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

FREE Newsletters Subscription

Get Interesting stuffs everyday in your mail, with a chance to win Rs. 10,000 every month by participating FREE Giveaway.