Instrukcja AAA

D.F.

Były Moderator
Dołączył
Listopad 4, 2009
Posty
493
Witam,
Mógłby mi ktoś wytłumaczyć co robi instrukcja AAA w języku Assembler? Czytałem dokumentację Intela, ale nadal nie rozumiem co dokładnie ta instrukcja wykonuje.
 

0wn3r

Były Moderator
Dołączył
Marzec 10, 2007
Posty
1330
AAA, czyli ASCII adjust after addition, oraz DAA decimal adjust for addition - są instrukcjami wsparcia dla BCD. Zazwyczaj instrukcje AAA stosuje się po add, adc, xadd.

AAA ASCII Adjust after Addition; Intel 80x86; changes the contents of register AL to a valid unpacked decimal number, and zeros the top 4 bits; sets or clears flags

Kod:
if ( (al and 0Fh) > 9 or (AuxC =1) ) then

        if (8088 or 8086) then 
                al := al + 6
        else 
                ax := ax + 6
        endif

        ah := ah + 1
        AuxC := 1               ;Set auxilliary carry
        Carry := 1              ; and carry flags.

else

        AuxC := 0               ;Clear auxilliary carry
        Carry := 0              ; and carry flags.
endif
al := al and 0Fh

Działa to używając tego algorytmu.

// jeśli chcesz przykład to pisz
 
Ostatnia edycja:

shoorick

Użytkownik
Dołączył
Lipiec 17, 2008
Posty
66
Kod:
    mov cl,5
    mov al,7
    add al,cl ; al=0Ch chyli 12
    aaa
wynik: ah=01(h) al=02(h)
jesli dodać 30h, to będzie 31h i 32h, chyli "1" i "2" - gotowe do druku liczby "12"
 
Do góry Bottom