8085 program to add three 16 bit numbers stored in registers
Problem – Write an assembly language program to add three 16 bit numbers stored in register HL, DE, BC and store the result in DE with minimum number of instructions.
Example –

Assumptions –
- Numbers to be added are already stored in register HL, DE, BC
- Numbers stored in register are such that final result should not be greater than FFFF
DAD D performs the following task:
H <- H + D L <- L + E
DAD instruction take one argument and that argument can be register B, D, H or SP XCHG instruction exchanges the content of register D with H and E with L
Algorithm –
- Add the content of DE register in HL and store the result in HL by help of DAD instruction
- Move the content of register B in D and C in E
- Repeat step 1
- Use XCHG instruction to swap the content of DE with HL. We will get the result in DE
Program –
| MEMORY ADDRESS | MNEMONICS | COMMENT | |
|---|---|---|---|
| 2000 | DAD D | H <- H + D, L <- L + E | |
| 2001 | MOV D, B | D <- B | |
| 2002 | MOV E, C | E <- C | |
| 2003 | DAD D | H <- H + D, L <- L + E | |
| 2004 | XCHG | Swap content of HL with DE | |
| 2005 | HLT | END |
Explanation –
- DAD D – adds the content of register D in H and register E in L and store the result in HL
- MOV D, B – moves the value of register B in register D
- MOV E, C moves the value of register C in register E
- Same as step 1
- XCHG – exchange the content of register H with register D and L with E.
- HLT – stops executing the program and halts any further execution
Recommended Posts:
- Registers of 8085 microprocessor
- 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 two 16 bit numbers
- 8085 program to add 2-BCD numbers
- 8085 program to swap two 8-bit numbers
- 8085 program to add numbers in an array
- 8085 program to sum of two 8 bit numbers without carry
- 8085 program to divide two 8 bit numbers
- 8085 program to multiply two 8 bit numbers
- 8085 program to divide two 16 bit numbers
- 8085 program to multiply two 16-bit numbers
- 8085 program to separate odd and even nos from a given list of numbers
- 8085 program to find larger of two 8 bit numbers
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.



