Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

8086 program to add two 16 bit BCD numbers with carry

  • Last Updated : 01 Jun, 2021

Problem – Write an assembly language program to add two 16 bit BCD numbers with carry in 8086 microprocessor. 

Example – 

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

 



Algorithm – 

  1. Load the lower part of both the 16 bit BCD numbers in different locations.
  2. Add each number by adding first its lower part.
  3. Repeat the above step also by adding the carry if any.
  4. Make the lower part of register 00 and add the carry. This is done to obtain the carry.
  5. Display all the mumbers with highest part as carry, middle part as addition of the higher BCD 8 bits and lower part as the lower BCD 8 bits.

Program – 

 

Memory AddressMnemonicsComments
0400MOV AL, [500]AL ← [500]
0404MOV BL, [502]BL ← [502]
0408ADD AL, BLAL ← AL+BL
040ADAADecimal Adjust AL
040BMOV [600], ALAL → [600]
040FMOV AL, [501]AL ← [501]
0413MOV BL, [503]BL ← [503]
0417ADC AL, BLAL ← AL+BL+CY
0419DAADecimal Adjust AL
041AMOV [601], ALAL → [601]
041EMOV AL, 00AL ← 00H
0420ADC AL, ALAL ← AL+AL+CY
0422MOV [602], ALAL → [602]
0426HLTStop Execution

Explanation – 
 

  1. MOV AL, [500] moves the value stored at memory location 500 to AL register.
  2. MOV BL, [502] moves the value stored at memory location 500 to BL register.
  3. ADD AL, BL add the values in AL and BL registers.
  4. DAA adds 6 to the digit which is greater than 9.
  5. MOV [600], AL display the added value to memory location 600.
  6. MOV AL, [501] moves the value stored at memory location 501 to AL register.
  7. MOV BL, [503] moves the value stored at memory location 503 to BL register.
  8. ADC AL, BL add the values in AL and BL registers and carry (if any).
  9. MOV BL, [503] moves the value stored at memory location 503 to BL register.
  10. MOV [601], AL display the added value to memory location 601.
  11. MOV AL, 00 moves 00 in AL register.
  12. ADC AL, AL add the values in AL and AL registers and carry (if any).
  13. MOV [602], AL display the added value to memory location 602.
  14. HLT stops execution.

Next related article – 8086 program to add two 8 bit BCD numbers
 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!