Advertisements
Advertisements
प्रश्न
Write procedure of DAA instruction to convert hexadecimal number in to Binary Coded Decimal (BCD) number with suitable example.
Advertisements
उत्तर
The DAA (Decimal Adjust Accumulator) instruction is used to convert the hexadecimal result of the addition of two BCD numbers into a valid packed BCD number. It is used only after the ADD/ADC/ADI instruction.
Procedure
-
Perform addition: Add two BCD numbers using
ADD/ADC/ADI. The result (in hexadecimal form) is stored in Accumulator (A). -
Check lower nibble (units digit): If lower nibble > 9 OR Auxiliary Carry (AC) = 1 → Add 06H to accumulator.
-
Check upper nibble (tens digit): After step 2, if upper nibble > 9
OR Carry flag (CY) = 1 → Add 60H to the accumulator.
-
Final result: The accumulator now contains a valid packed BCD number. If CY = 1, it indicates an extra digit (hundreds).
Add 68 and 85 (BCD numbers)
Perform addition → 68H + 85H = EDH
Lower nibble check → EDH + 06H = F3H
Upper nibble check → F3H + 60H = 153H
Final result
A = 53H
CY = 1
