-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
I have discovered a few disassembly issues with M68K. While fixing these, I have noticed that m68k_op_mem.in_disp and .out_disp are uint32_t. However, M68K displacements are signed.
M68K displacements can be 8, 16 or 32 bit. The 8 bit displacement is placed in .disp, which is int16_t, so this is correct. The 16 and 32 bit displacements are placed in .in_disp and .out_disp depending on their meaning in the EA. Since .in_disp and .out_disp are unsigned, and the 16 bit displacement is not sign-extended, this is the source of one of the issues I have discovered. The sign bit in the displacement fields is incorrect with 16 bit displacements. The unsignedness causes a great deal of confusion and guesswork, since it does not seem to be documented. It also means there's a bit of two's complement magic is implemented in several places to work around this, for instance objdump-m68k.py.
As part of my upcoming PR, would it be possible to for me to change the signedness of .in_disp and .out_disp? Unfortunately it also means updating several python files, which I am not comfortable with. Working around this unfortunate typing will introduce further two's complement magic.