8086 program to subtract two 16 bit BCD numbers
Prerequisite – 8086 program to subtract two 8 bit BCD numbers
Problem – Write a program in 8086 microprocessor to find out the subtraction of two 16-bit BCD numbers, where numbers are stored from starting offset 500 and store the result into offset 600.
Example –

Algorithm –
- Load data from offset 500 to register AL
- Load data from offset 502 to register BL
- Subtract these two numbers (contents of register AL and register BL)
- Apply DAS instruction (decimal adjust)
- Store the result (content of register AL) to offset 600
- Load data from offset 501 to register AL
- Load data from offset 503 to register BL
- Subtract these two numbers with borrow.(contents of register AL and register BL)
- Apply DAS instruction (decimal adjust)
- Store the result (content of register AL) to offset 601
- Set register AL to 00
- Add contents of register AL to itself with carry
- Store the result (content of register AL) to offset 602
- Stop
Program –
| MEMORY ADDRESS | MNEMONICS | COMMENT |
|---|---|---|
| 400 | MOV AL, [500] | AL<-[500] |
| 404 | MOV BL, [502] | BL<-[502] |
| 408 | SUB AL, BL | AL<-AL-BL |
| 40A | DAS | decimal adjust |
| 40B | MOV [600], AL | AL->[600] |
| 40F | MOV AL, [501] | AL<-[501] |
| 413 | MOV BL, [503] | BL<-[503[ |
| 417 | SBB AL, BL | AL<-AL-BL-borrow |
| 419 | DAS | decimal adjust |
| 41A | MOV [601], AL | AL->[601] |
| 41E | MOV AL, 00 | AL<-00 |
| 420 | ADC AL, AL | AL<-AL+AL+borrow |
| 422 | MOV [602], AL | A->[602] |
| 426 | HLT | End |
Explanation –
- MOV AL, [500]: load data from offset 500 to register AL
- MOV BL, [502]: load data from offset 502 to register BL
- SUB AL, BL: subtract contents of registers AL AND BL
- DAS: decimal adjust
- MOV [600], AL: store data from register AL to offset 600
- MOV AL, [501]: load data from offset 501 to register AL
- MOV BL, [503]: load data from offset 503 to register BL
- SBB AL, BL: subtract contents of registers AL AND BL with borrow
- DAS: decimal adjust
- MOV [601], AL: store data from register AL to offset 601
- MOV AL, 00: set value of register AL to 00
- ADC AL, AL: add contents of register AL to AL with carry
- MOV [601], AL: store data from register AL to offset 601
- HLT: end
Recommended Posts:
- 8086 program to subtract two 8 bit BCD numbers
- 8086 program to subtract two 16-bit numbers with or without borrow
- 8085 program to subtract two 8-bit numbers with or without borrow
- 8085 program to subtract two 16-bit numbers with or without borrow
- 8086 program to determine cubes of numbers in an array of n numbers
- 8086 program to determine squares of numbers in an array of n numbers
- 8086 program to add two 8 bit BCD numbers
- 8086 program to multiply two 16-bit numbers
- 8086 program to add two 16 bit BCD numbers with carry
- 8086 program to add two 16-bit numbers with or without carry
- 8086 program to multiply two 8 bit numbers
- 8086 program to generate AP series of n numbers
- 8086 program to generate G.P. series of n numbers
- 8086 program to find sum of Even numbers in a given series
- 8086 program to find average of n 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.



