In assembly language 8086 we use mnemonics in order to perform arithmetic operations like SUB/SBB in subtraction.
So, Let's dive deep into what SUB and SBB is ...
SUB:- It subtracts the data in source from data in destination and then stores result in destination. Source can be memory location or register or a number but destination should be register or a memory location(not immediate number). Remember that source and destination should be of same type and both shouldn't be memory locations.
Syntax: SUB <destination> <source>
Operation: destination← destination - source
SBB:- It is used to subtract source-operand and borrow. from destination-operand and then the result is stored in destination. Source can be memory location or register or a number but destination should be register or a memory location(not immediate number). Remember that source and destination should be of same type and both shouldn't be memory locations.
Syntax: SBB <destination> <source>
Operation: destination← destination - source - carry flag
DAS:- Usually used after SUB/SBB because DAS works on AL registers. This instruction is used to convert result of subtraction of 2packed numbers into 1-packed BCD number. in simple language, SUB/SBB adds BCD number in hexadecimal format and then DAS instruction converts this hexadecimal result into BCD result.
Syntax: DAS
Which flags get affected?
Ans- OF , CF, PF , AF, SF , ZF .
Addition of 8-bit BCD8086 program
So, Let's dive deep into what SUB and SBB is ...
SUB:- It subtracts the data in source from data in destination and then stores result in destination. Source can be memory location or register or a number but destination should be register or a memory location(not immediate number). Remember that source and destination should be of same type and both shouldn't be memory locations.
Syntax: SUB <destination> <source>
Operation: destination← destination - source
SBB:- It is used to subtract source-operand and borrow. from destination-operand and then the result is stored in destination. Source can be memory location or register or a number but destination should be register or a memory location(not immediate number). Remember that source and destination should be of same type and both shouldn't be memory locations.
Syntax: SBB <destination> <source>
Operation: destination← destination - source - carry flag
DAS:- Usually used after SUB/SBB because DAS works on AL registers. This instruction is used to convert result of subtraction of 2packed numbers into 1-packed BCD number. in simple language, SUB/SBB adds BCD number in hexadecimal format and then DAS instruction converts this hexadecimal result into BCD result.
Syntax: DAS
Which flags get affected?
Ans- OF , CF, PF , AF, SF , ZF .
data segment
no1 dw 21h
no2 dw 31h
ans dw ?
data ends
code segment
start : assume cs :code, ds :data
mov ax ,data
mov ds , ax
mov ax , no1
mov bx , no2
SUB ax , bx
DAS
mov ans ,ax
mov ah ,4ch
int 21h
code ends
end start
Addition of 8-bit BCD8086 program
Subtraction of 16-bit BCD program
Programs:-
For many other Assembly Language Programs related to microprocessor 8086 visit our BLOG
There are programs of largest ,smallest ,division ,multiplication,odd/even,block operation ,string operations,BCD ,etc
For many other Assembly Language Programs related to microprocessor 8086 visit our BLOG
There are programs of largest ,smallest ,division ,multiplication,odd/even,block operation ,string operations,BCD ,etc
No comments:
Post a Comment