x86reference icon indicating copy to clipboard operation
x86reference copied to clipboard

JMP use wrong operand type

Open Kashio opened this issue 2 years ago • 3 comments

Right now JMP encoded with opcodes EB use operand type bs for its operand of addressing J which is defined as:

Byte, sign-extended to the size of the destination operand.

The problem is that the immediate is always sign extended to the size of the stack pointer. Therefore the most appropriate operand type for these should be bss:

Byte, sign-extended to the size of the stack pointer (for example, PUSH (6A)).

Kashio avatar Apr 15 '23 12:04 Kashio

Hello, I'm sorry for not being responsive. Thank you for your review.

The Jbs actually reads as: "Relative offset to be added to the IP register. The relative offset is sign-extended to the size of of the IP register."

I think you are confused by the bs being "Byte, sign-extended to the size of the destination operand.". The destination operand is determined by J addressing so it is either IP, EIP or RIP.

BarebitOpenSource avatar Apr 16 '23 10:04 BarebitOpenSource

Hey, I see what you mean, maybe a better solution would be to add to all such instructions:

  "dst": [
    {
      "_address": "??",
      "_displayed": "no",
      "__text": "[rIP]"
    }
  ],

Since bs is not an official operand type according to the docs and the interpretation of

Byte, sign-extended to the size of the destination operand.

is confusing if no destination operand is mentioned in the instruction, although the J addressing implies it I think it would be better to add it since it is more semantically correct as per the description, what do you think?

Kashio avatar Apr 23 '23 14:04 Kashio

Good point. It seems that all what needs to be done is to correct the description of bs to "Byte, sign-extended to the size of the ~destination~ operand."

Well, the J addressing is tricky. To make it completely correct, it should be a destination operand but it would make the byte value also the destination and that doesn't make much sense. This would need to be solved by introducing new types of operands but I don't think it's worth it.

BarebitOpenSource avatar Jan 31 '24 19:01 BarebitOpenSource

Added to the main README but ref.x86asm.net needs to fixed.

BarebitOpenSource avatar May 13 '24 19:05 BarebitOpenSource

Moved to https://github.com/mazegen/x86reference/issues/9

BarebitOpenSource avatar Jun 05 '24 14:06 BarebitOpenSource