Write an 8085 program to add two 8-bit hexadecimal numbers sum equals to 16-bit - ChromeTechny
Home » Write an 8085 program to add two 8-bit hexadecimal numbers sum equals to 16-bit
8085

Write an 8085 program to add two 8-bit hexadecimal numbers sum equals to 16-bit

In this posts, we are going to learn how we can add two 8-bit hexadecimal numbers which will produce an output of a 16-bit number. Now in order to so, we are going to take two 8-bit hexadecimal numbers which will produce a carry.

Unless and until a carry will produce, we won’t be able to use the concept of LSB and MSB in this program.

Now, as per as memory location is concerned, we will require two memory location to store the value and two memory location to store the result.

Input:

As mentioned, we are going to need 4 consecutive memory locations; so we are going to use 2000H to 2003H memory location.

In the first two memory locations i.e. 2000H and 2001H, we are going to store 8-bit data EAH and D8H, which after addition will produce an output C2H with carry 1.

And then we are going to store C2H in 2002H and carry 1 in 2003H location.

Instruction:

LXI H,2000H

MVI C,00H

MOV A, M

INX H

ADD M

JNC Label

INR C

Label STA 2002H

MOV A,C

STA 2003 H

HLT

Programming Details
Memory Location OPCODE Operand Label Hex Code
2004 LXI H, 2000H 21H
2005 00H
2006 21H
2007 MVI C,00 OEH
2008 00H
2009 MOV A,M 7EH
200A INX H 23H
200B ADD M 23H
200C JNC Label 0CH
200D 10H
200E 20H
200F INR C 0CH
2010 STA 2003 32H
2011 02H
2012 20H
2013 MOV A,C 79H
2014 STA 2003 32H
2015 03H
2016 20H
2017 HLT 76H

 

About the author

Ayan