asm-differ icon indicating copy to clipboard operation
asm-differ copied to clipboard

x86 negative immediate matches positive immediate

Open 1superchip opened this issue 7 months ago • 1 comments

-0x8 is not being considered different than 0x8 as an immediate.

Possibly needs to update the re_imm regex to capture -

Current regex: re_imm=re.compile(r"-?(0x[0-9a-f]+|[0-9]+)|([\?$_][^ \t,]+)")

Image

Scratch: https://decomp.me/scratch/3rDWd

Image: Image

1superchip avatar May 15 '25 17:05 1superchip

After spending some time on this, it seems that the stack regex (re_sprel) actually needs to be updated to capture - if it exists. The diff is related to %ebp which is a stack register.

Current: re_sprel=re.compile(r"-?(0x[0-9a-f]+|[0-9]+)(?=\((%ebp|%esi)\))")

Changed: re_sprel=re.compile(r"(-?0x[0-9a-f]+|[0-9]+)(?=\((%ebp|%esi)\))")

The other regexes might need to be updated too? re_imm does not capture - either. re_imm=re.compile(r"-?(0x[0-9a-f]+|[0-9]+)|([\?$_][^ \t,]+)")

1superchip avatar May 16 '25 18:05 1superchip