Problem – Write a program to subtract two 16-bit numbers where starting address is 2000 and the numbers are at 3000 and 3002 memory address and store result into 3004 and 3006 memory address.
- Load 0000H into CX register (for borrow)
- Load the data into AX(accumulator) from memory 3000
- Load the data into BX register from memory 3002
- Subtract BX with Accumulator AX
- Jump if no borrow
- Increment CX by 1
- Move data from AX(accumulator) to memory 3004
- Move data from CX register to memory 3006
|2000||MOV||CX, 0000||[CX] <- 0000|
|2003||MOV||AX, ||[AX] <- |
|2007||MOV||BX, ||[BX] <- |
|200B||SUB||AX, BX||[AX] <- [AX] – [BX]|
|200D||JNC||2010||Jump if no borrow|
|200F||INC||CX||[CX] <- [CX] + 1|
|2010||MOV||, AX|| <- [AX]|
|2014||MOV||, CX|| <- [CX]|
- MOV is used to load and store data.
- SUB is used to subtract two numbers where their one number is in accumulator or not.
- JNC is a 2-bit command which is used to check whether the borrow is generated from accumulator or not.
- INC is used to increment an register by 1.
- HLT is used to stop the program.
- AX is an accumulator which is used to load and store the data.
- BX, CX are general purpose registers where BX is used for storing second number and CX is used to store borrow.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- 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 subtract two 8 bit BCD numbers
- 8086 program to subtract two 16 bit BCD numbers
- 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 8 bit numbers
- 8086 program to add two 16-bit numbers with or without carry
- 8086 program to multiply two 16-bit numbers
- 8086 program to add two 16 bit BCD numbers with carry
- 8086 program to find sum of Even numbers in a given series
- 8086 program to find average of n numbers
- 8086 program to find GCD of two numbers and print the GCD
- 8086 program to generate AP series 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 email@example.com. 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.