# 8085 program to add two 16 bit numbers

**Problem –** Write an assembly language program to add two 16 bit numbers by using:

- (a) 8 bit operation
- (b) 16 bit operation

**Example –**

**(a) Addition of 16 bit numbers using 8 bit operation –** It is a lengthy method and requires more memory as compared to 16 bit operation.

**Algorithm –**

- Load the lower part of first number in B register
- Load the lower part of second number in A (accumulator)
- Add both the numbers and store
- Load the higher part of first number in B register
- Load the higher part of second number in A (accumulator)
- Add both the numbers with carry from the lower bytes (if any) and store at the next location

**Program –**

MEMORY ADDRESS | MNEMONICS | COMMENTS |
---|---|---|

2000 | LDA 2050 | A ← 2050 |

2003 | MOV B, A | B ← A |

2004 | LDA 2052 | A ← 2052 |

2007 | ADD B | A ← A+B |

2008 | STA 3050 | A → 3050 |

200B | LDA 2051 | A ← 2051 |

200E | MOV B, A | B ← A |

200F | LDA 2053 | A ← 2053 |

2012 | ADC B | A ← A+B+CY |

2013 | STA 3051 | A → 3051 |

2016 | HLT | Stops execution |

**Explanation –**

**LDA 2050**stores the value at 2050 in A (accumulator)**MOV B, A**stores the value of A into B register**LDA 2052**stores the value at 2052 in A**ADD B**add the contents of B and A and store in A**STA 3050**stores the result in memory location 3050**LDA 2051**stores the value at 2051 in A**MOV B, A**stores the value of A into B register**LDA 2053**stores the value at 2053 in A**ADC B**add the contents of B, A and carry from the lower bit addition and store in A**STA 3051**stores the result in memory location 3051**HLT**stops execution

**(b) Addition of 16 bit numbers using 16 bit operation –** It is a very short method and less memory is also required as compared to 8 bit operation.

**Algorithm –**

- Load both the lower and the higher bits of first number at once
- Copy the first number to another register pair
- Load both the lower and the higher bits of second number at once
- Add both the register pairs and store the result in a memory location

**Program –**

MEMORY ADDRESS | MNEMONICS | COMMENTS |
---|---|---|

2000 | LHLD 2050 | A ← 2050 |

2003 | XCHG | D ← H & E ← L |

2004 | LHLD 2052 | A ← 2052 |

2007 | DAD D | H ← H+D & L ← L+E |

2008 | SHLD 3050 | A → 3050 |

200B | HLT | Stops execution |

**Explanation –**

**LHLD 2050**loads the value at 2050 in L register and that in 2051 in H register (first number)**XCHG**copies the content of H to D register and L to S register**LHLD 2052**loads the value at 2052 in L register and that in 2053 in H register (second number)**DAD D**adds the value of H with D and L with E and stores the result in H and L**SHLD 3050**stores the result at memory location 3050**HLT**stops execution

## Recommended Posts:

- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to count total odd numbers in series of 10 numbers
- 8085 program to add two 8 bit numbers
- 8085 program to add 2-BCD numbers
- 8085 program to add numbers in an array
- 8085 program to multiply two 16-bit numbers
- 8085 program to sum of two 8 bit numbers without carry
- 8085 program to divide two 16 bit numbers
- 8085 program to divide two 8 bit numbers
- 8085 program to swap two 8-bit numbers
- 8085 program to multiply two 8 bit numbers
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find the sum of first n natural numbers
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to subtract two 8-bit numbers with or without borrow

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.