In this program we will see how to add two 16-bit BCD numbers with carry.
Write 8086 Assembly language program to add two 16-bit BCD numbers stored in memory offset 500H – 501H and 502H – 503H.
Here we are adding the 16-bit data byte by byte. At first we are adding lower byte and perform the DAA instruction, then Add higher bytes with carry, and again DAA to adjust. The final result is stored at location offset 600H, and if carry is present, it will be stored at 601H.
We are taking two numbers 8523 + 7496 = 16019
Address | Data |
---|---|
… | … |
500 | 23 |
501 | 85 |
502 | 96 |
503 | 74 |
… | … |
Address | Data |
---|---|
… | … |
600 | 19 |
601 | 60 |
602 | 01 |
… | … |