subtraction

Assembly Language Program to Subtract Values of Registers Using SUB instruction

SUB is keyword used for subtraction for two values. It also needs two operands, destination and source. After subtraction, answer is stored in destination address. It syntax is as follows:

SUB destination, source

Examples are as follows:

  • SUB DL, 4
  • SUB AL, Var1

An example of assembly program using SUB is written below:

.model small
.stack 100h
.data
.code
main proc
mov bl, 5
mov dl, 3
SUB dl, bl
Add dl, 48
mov ah, 2
INT 21h
mov ah, 4ch
INT 21h

main endp
end main

Leave a Reply

Your email address will not be published. Required fields are marked *