Open In App
Related Articles

8085 program to add two 8 bit numbers

Improve Article
Improve
Save Article
Save
Like Article
Like

Problem – Write an assembly language program to add two 8 bit numbers stored at address 2050 and address 2051 in 8085 microprocessor. The starting address of the program is taken as 2000. 

Example – 

 

Algorithm – 
 

  1. Load the first number from memory location 2050 to accumulator.
  2. Move the content of accumulator to register H.
  3. Load the second number from memory location 2051 to accumulator.
  4. Then add the content of register H and accumulator using “ADD” instruction and storing result at 3050
  5. The carry generated is recovered using “ADC” command and is stored at memory location 3051

Program – 

 

Memory AddressMnemonicsComment
2000LDA 2050A<-[2050]
2003MOV H, AH<-A
2004LDA 2051A<-[2051]
2007ADD HA<-A+H
2008MOV L, AL←A
2009MVI A 00A←00
200BADC AA←A+A+carry
200CMOV H, AH←A
200DSHLD 3050H→3051, L→3050
2010HLT 

Explanation – 

 

  1. LDA 2050 moves the contents of 2050 memory location to the accumulator.
  2. MOV H, A copies contents of Accumulator to register H to A
  3. LDA 2051 moves the contents of 2051 memory location to the accumulator.
  4. ADD H adds contents of A (Accumulator) and H register (F9). The result is stored in A itself. For all arithmetic instructions A is by default an operand and A stores the result as well
  5. MOV L, A copies contents of A (34) to L
  6. MVI A 00 moves immediate data (i.e., 00) to A
  7. ADC A adds contents of A(00), contents of register specified (i.e A) and carry (1). As ADC is also an arithmetic operation, A is by default an operand and A stores the result as well
  8. MOV H, A copies contents of A (01) to H
  9. SHLD 3050 moves the contents of L register (34) in 3050 memory location and contents of H register (01) in 3051 memory location
  10. HLT stops executing the program and halts any further execution

 

Last Updated : 28 Jun, 2022
Like Article
Save Article
Similar Reads