x86reference icon indicating copy to clipboard operation
x86reference copied to clipboard

Possible error in PUSH immediate

Open klkblake opened this issue 8 years ago • 1 comments

The PUSH immediate encodings list the operands types as Ibss and Ivs, the descriptions for which state that they are sign-extended to the size of the stack pointer (which is fixed at 64 bits in 64 bit mode). However, the Intel manual states that immediate operands to PUSH are sign-extended to the operand size, which defaults to 64 bits in 64 bit mode but may be set to 16 bits using the operand size override prefix. Testing indicates that this does in fact work and it's sign extended to the operand size as the Intel manual states.

klkblake avatar Nov 06 '17 07:11 klkblake

Good point. I don't have the original Intel manual that's been around when I wrote the reference but I'd swear the operation was described as follows:

  1. the immediate value is sign-extended to the size of stack pointer (64 bits in 64-bit mode)
  2. the value is truncated according to operand size (64 or 16 bits in 64-bit mode)
  3. the result is pushed to stack

Now, the Ibss and Ivs cover only the first point, i.e. that the immediate is sign-extended. The rest belongs to operand size rules. Anyway, I will think about updating the description.

And sorry for late response.

BarebitOpenSource avatar Feb 04 '19 23:02 BarebitOpenSource