reko icon indicating copy to clipboard operation
reko copied to clipboard

X86 logical instructions need to model the O(verflow) flag more precisely

Open uxmal opened this issue 5 years ago • 1 comments

As part of implementing support for the X86 adox instruction I discovered that the logical instructions need to be rewritten to model the processor more accurately. For example, the and eax,ebx instruction is being rewritten as:

eax = eax & ebx
SZO = cond(eax)
C = false

but it should be:

eax = eax & ebx
SZ = cond(eax)
C = false
O = false

The Intel documentation specifies that to start a chain of adox instructions for computing additions of "bignums", the overflow flag should be cleared.

While the current implementation is correct, the change proposed here is more precise and will make adox chains decompile more accurately.

uxmal avatar Sep 13 '20 07:09 uxmal

Just my two cents: The SF, ZF and PF can be computed just from the result. For the other flags you need the operation (not, inc, add,...) and maybe also the input values. So SZO = cond(eax) looks wrong but SZ = cond(eax) looks possible.

rfalke avatar Sep 16 '20 17:09 rfalke