helppc talks of it sayin that it Corrects result (in AL) of a previous BCD addition operation. Contents of AL are changed to a pair of packed decimal digits. But i cant understand a thing from it. What is BCD(Binary Coded Decimal). BTW, What is "packed" decimal digits? What is daa?
Posted on 2001-06-18 10:43:00 by MovingFulcrum
From Intel's "IA-32 Intel Architecture Software Developer's Manual":
Description Adjusts the sum of two packed BCD values to create a packed BCD result. The AL register is the implied source and destination operand. The DAA instruction is only useful when it follows an ADD instruction that adds (binary addition) two 2-digit, packed BCD values and stores a byte result in the AL register. The DAA instruction then adjusts the contents of the AL register to contain the correct 2-digit, packed BCD result. If a decimal carry is detected, the CF and AF flags are set accordingly. Operation IF (((AL AND 0FH) > 9) or AF <- 1) THEN AL <- AL + 6; CF <- CF OR CarryFromLastAddition; (* CF OR carry from AL <- AL + 6 *) AF <- 1; ELSE AF <- 0; FI; IF ((AL AND F0H) > 90H) or CF <-1) THEN AL <- AL + 60H; CF <- 1; ELSE CF <- 0; FI;
May be a little more clear ( :confused: / :D )! Basically BCD is groups of 4 bits, that represent a number between 0 and 9 (basically hex without A -> F), so 033h as a BCD byte is 33 in decimal! Mirno P.S. I might be wrong. *** Edited out messed up symbols from Intel Doc *** This message was edited by Mirno, on 6/18/2001 12:10:03 PM
Posted on 2001-06-18 12:06:00 by Mirno
    mov al, 012h  ;BCD for 12 decimal
    mov bl, 019h  ;BCD for 19 decimal

    add al, bl    ;12 + 19
;al = 02Bh
    daa           ;correct carry to next nibble
;al = 031h this is BCD for 31 decimal!
If the carry wasn't corrected you'd have the wrong answer. This instruction locks the value of each nibble to the decimal range and carries the overflow to the next significant nibble. BCD numbering is easy to convert to ASCII, and was used for multi-byte math functions. There are faster ways, so these instructions have taken a back seat. Note: A nibble is a term used for half a byte. ;)
Posted on 2001-06-18 12:41:00 by bitRAKE
So do i. (With a little more explanation from disease_200) :D
Posted on 2001-06-19 10:38:00 by MovingFulcrum