8086 Assembly Subtraction: 8-bit and 16-bit

To understand the subtraction process in x86 Assembly language, you must go through some important topics we shared earlier:

To perform subtraction in x86 assembly we have to use SUB opcode and different registers for 8-bit and 16-bit numbers.

x86 Assembly Subtraction of 16-bit Numbers

Q: Write a program, take two 16-bit numbers of your choice, perform subtraction them and display the result.

PROGRAM

EXPLANATION

In the above program, we initialized two variables b and c with hexadecimal values. we use data type DW because we are performing 16-bit subtraction. Then we use SUB opcode to perform subtraction and we added 30h to the result to show the result in integer form rather that hexadecimal form.


x86 Assembly Subtraction of 8-bit Numbers

Q: Write a program, take two 8-bit numbers of your choice, perform subtraction them and display the result.

PROGRAM

EXPLANATION

The above program is for 8-bit subtraction so we use 8-bit register AL, BL, CL, DL. All the other process is same as for 32-bit subtraction.

Hope so this tutorial will help you understand the basics of 8086 Subtraction. Comment to show me that you are alive!

Nauman Rehmat
 

Nauman Rehmat is the owner of Assembly Language Tuts.He is interested in Programming and SEO. He is also pursuing a degree in Computer Software Engineering from Comsats.