Open mfaerevaag opened 7 years ago
Let me elaborate a little bit on this issue. First of all the prefix here doesn't really matter, the issue is observed even without it;
bap-mc "660fc1c0" --show-bil --arch=X86 --show-insn=asm
xaddw %ax, %ax
{
v1 := low:16[EAX] + low:16[EAX]
EAX := extract:31:16[EAX].low:16[EAX]
EAX := extract:31:16[EAX].v1
CF := low:16[EAX] < v1
OF := high:1[v1] = high:1[low:16[EAX]] & (high:1[v1] ^ high:1[low:16[EAX]])
AF := 0x10 = (0x10 & (low:16[EAX] ^ v1 ^ low:16[EAX]))
PF := ~low:1[let v2 = low:16[EAX] >> 4 ^ low:16[EAX] in
let v2 = v2 >> 2 ^ v2 in
v2 >> 1 ^ v2]
SF := high:1[low:16[EAX]]
ZF := 0 = low:16[EAX]
}
Indeed, in CF := low:16[EAX] < v1
the left hand side of the comparison low:16[EAX]
will be always equal to the right hand side, since it was assigned in the previous statement. So it will be always false.
Description
Invalid calculation of the carry flag,
CF
, when executingxadd
instruction with the0xc0
as operand and prefixed as below.Reference: Ref. Intel 64 and IA-32 Architecture Software Developer's Manual Vol. 5-580 Vol. 2C
Affected instructions:
Reproduction guide
Instruction:
Input:
Observed output:
Expected output: With this implementation,
CF
is only set to zero.System Info
OS:
BAP: