Write an 8085 program to evaluate the expression y=a+b+c, where a,b and c are 8-bit hexadecimal numbers - ChromeTechny
Home » Write an 8085 program to evaluate the expression y=a+b+c, where a,b and c are 8-bit hexadecimal numbers
8085 Programming

Write an 8085 program to evaluate the expression y=a+b+c, where a,b and c are 8-bit hexadecimal numbers

I hope you have gotten a clear idea on how you can do addition operation using 16-bit hexadecimal and decimal number.

In this program, we are going evaluate the above expression, which basically means the addition of three consecutive numbers, and all of them are 8-bit hexadecimal numbers.

As far as addressing mode is concerned, we are going to use indirect addressing mode. And the result will be stored in a memory location, not in a general purpose register.

Input:

Let a = A9H, which will be stored at the 2000H memory location, b = 2DH, which we will be storing in the 2001H memory location, and finally c = 1BH, which will be stored at the 2002H memory location.

After the evaluation, the final result will be stored at the 2003H memory location, so in total, we are going to use 4 consecutive memory locations.

Program:

LXI H, 2000H // using LXI H, we will use HL register to point at 2000H memory location

MOV A, M // we now store the content of 2000H memory location in the accumulator using the MOV instruction

INX H // we will increment the HL register as a result, it will point at 2001H memory location

ADD M // now we will perform the addition operation between the content of accumulator and the content of HL register pair

INX H // again we are going to use HL register pair to increment the ML which will now be pointing at 2003H memory location

ADD M // this time we are going perform the addition operation between the output of the first addition which has been stored in the accumulator with the content of HL register pair

STA 2003 // using STA we are going to store the content of accumulator in 2003H memory location

 

HLT

Programming Details
Memory Location OPCODE Operand Label Hex Code
2004 LXI H, 2000H 21H
2005 00H
2006 20H
2007 MOV A,M 7EH
2008 INX H 23H
2009 ADD M 86H
200A INX H 23H
200B ADD M 86
200C STA 2003 32H
200D 03H
200E 20H
200F HLT 76H

About the author

Ayan