Open In App
Related Articles

8086 program to add two 8 bit BCD numbers

Improve Article
Improve
Save Article
Save
Like Article
Like

Problem – Write a program in 8086 microprocessor to find out the addition of two 8-bit BCD numbers, where numbers are stored from starting memory address 2000 : 500 and store the result into memory address 2000 : 600 and carry at 2000 : 601.

Example –

Algorithm –

  1. Load data from offset 500 to register AL (first number)
  2. Load data from offset 501 to register BL (second number)
  3. Add these two numbers (contents of register AL and register BL)
  4. Apply DAA instruction (decimal adjust)
  5. Store the result (content of register AL) to offset 600
  6. Set register AL to 00
  7. Add contents of register AL to itself with carry
  8. Store the result (content of register AL) to offset 601
  9. Stop

Program –

MEMORY ADDRESS MNEMONICS COMMENT
400 MOV AL, [500] AL<-[500]
404 MOV BL, [501] BL<-[501]
408 ADD AL, BL AL<-AL+BL
40A DAA DECIMAL ADJUST AL
40B MOV [600], AL AL->[600]
40F MOV AL, 00 AL<-00
411 ADC AL, AL AL<-AL+AL+cy(prev)
413 MOV [601], AL AL->[601]
417 HLT END

Explanation –

  1. MOV AL, [500]: load data from offset 500 to register AL
  2. MOV BL, [501]: load data from offset 501 to register BL
  3. ADD AL, BL: ADD contents of registers AL AND BL
  4. DAA: decimal adjust AL
  5. MOV [600], AL: store data from register AL to offset 600
  6. MOV AL, 00: set value of register AL to 00
  7. ADC AL, AL: add contents of register AL to AL with carry
  8. MOV [601], AL: store data from register AL to offset 601
  9. HLT: stop
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 22 May, 2018
Like Article
Save Article
Previous
Next
Similar Reads