Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.
1093 Discussions

question about DAA(opcode 0x27) instruction's operation

Gun_Woo_K_
Beginner
402 Views

Hi,

I'm currently writing a x86 code emulator.

So I need to know detailed instruction's operation.

 

I was writing a DAA instruction, detailed operation is like this,

 

old_AL ← AL;
old_CF ← CF;
CF ← 0;
IF (((AL AND 0FH) > 9) or AF = 1)
    THEN
        AL ← AL + 6;
        CF ← old_CF or (Carry from AL ← AL + 6);
        AF ← 1;
    ELSE
        AF ← 0;
FI;
IF ((old_AL > 99H) or (old_CF = 1))
    THEN
        AL ← AL + 60H;
        CF ← 1;
    ELSE
        CF ← 0;
FI;

 

I'm just wondering about whether constant 0x99 is correct or not.

Somebody(from the internet) said  0x9F was right, but the intel manual says 0x99 is right.

Which one is correct?

 

I need exactly answer from Intel hardware engineering contacts.

Thank you.

 

0 Kudos
1 Reply
SHIH_K_Intel
Employee
402 Views

If the threshold value is 9FH, that meant an input value of 9AH will become A0H, which is not a packed BCD value in one byte.

With the threshold value of 99H, 9AH will be adjusted by DAA into 00H, which is the wrapped result one would expect out of 1 byte packed BCD.

0 Kudos
Reply