Home › Forums › 8085 Microprocessor Code Library › Add two 8-bit numbers
Tagged: Add two 8 bit numbers, Add the contents of memory
This topic contains 2 replies, has 3 voices, and was last updated by YT2095 5 years, 2 months ago.
Add the contents of memory locations 4000H and 4001H and place the result in memory location 4002H.
(4000H) = 14H
(4001H) = 89H
Result = 14H + 89H = 9DH
LXI H 4000H : HL points 4000H
MOV A, M : Get first operand
INX H : HL points 4001H
ADD M : Add second operand
INX H : HL points 4002H
MOV M, A : Store result at 4002H
HLT : Terminate program execution
I tried to run the program, but I get error on the first line. It shows that the format you have used with LXI is incompatible.
I`m not sure if it helps but, LD HL,nn in this instance would read 2A 00 40.
this will put the number 0x4000 into the HL register.
to load the Contents of the location 0x4000 into HL then it`s simply 21 00 40.
Also on Twitter as: “YT2095”
You must be logged in to reply to this topic.