Subtraction of two BCD numbers

Statement: Subtract the BCD number stored in E register from the number stored in the D register.

Source Program: 
MVI A,99H
SUB E : Find the 99's complement of subtrahend
INR A : Find 100's complement of subtrahend
ADD D            : Add minuend to 100's complement of subtrahend
DAA : Adjust for BCD
HLT : Terminate program execution
Note: When two BCD numbers are subtracted, we can use DAA instruction for ajusting the result to BCD. Therefore, the subtraction of BCD number is carried out 10's complement or 100's complement.
The 10's complement of a decimal number is equal to the 99's complement plus 1. The 99's complement of a number can be found by subtracting the number from 99.
The steps for finding 100's complement BCD subtraction are :
  • Find the 100's complement of subtrahend
  • Add two numbers using BCD adition

Post a Comment

0 Comments

Close Menu