s

8086 SUB Instruction edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 13 February 2021 | 3861

Sub is an arithmetic instruction that subtracts the second operand with the first and stores the result in the first operand.

the second operand can be an immediate number, a register, or a memory location. & the first operand also can be a general-purpose register or a memory location. both operands can be a byte or a word and should be of the same size. If you need to add an 8 bit value ( byte ) to a word you must copy the byte to word location and fill the upper byte of the word with zero before addition.

following flags are affected by an add instruction

AF, CF, OF, SF, ZF

Types of operands supported

Instruction	Operands
----------------------------
SUB		REG, memory
		memory, REG
		REG, REG
		memory,immediate
		REG,immediate 

Example

mov al,10	; copy the value 10 to al
sub al,02	; the value of al will be 8 after addition