question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect operand-size for IP/EIP/RIP register?

See original GitHub issue

I’m not sure if this is an actual issue, but I played with the JMP (0xE9) instruction and got the following results for the suppressed instruction-pointer operand in 32-bit mode:

1. xed-ex1 e900000000 -> REG0=EIP SUPPRESSED RW V 32 2. xed-ex1 66e900000000 -> REG0=EIP SUPPRESSED RW V 16 3. xed-ex1 67e900000000 -> REG0=IP SUPPRESSED RW V 32 4. xed-ex1 6766e900000000 -> REG0=IP SUPPRESSED RW V 16

Especially the third one looks fishy, because the operand-size is 32-bit, but the register (IP) itself is only 16-bits wide.

The Intel doc contains the following pseudo code, where EIP is always accessed as a full register (32-bit) regardless of the effective operand-size:

IF OperandSize = 32
  THEN
    EIP ← tempEIP;
  ELSE
    IF OperandSize = 16
      THEN (* OperandSize = 16 *)
        EIP ← tempEIP AND 0000FFFFH;
      ELSE (* OperandSize = 64)
        RIP ← tempRIP;
    FI;
FI;

Therefore I think the actual XED-operand-size for IP/EIP/RIP should always be the total width of the used register regardless of the effective-operand-size.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
markcharneycommented, Jun 30, 2017

Sorry about the delay. Pushed changes to master. Thanks for the issue(s). Let me know if you encounter any others!

1reaction
markcharneycommented, Jun 21, 2017

I have to review a bunch of instructions that use rIP() before I push my fix. Working on this…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Operand size conflict in x86 Assembly? - Stack Overflow
I have a character stored in the EAX register, but I need to move it to my DL register. When I try: mov...
Read more >
`push`'s operand should sign-extend immediate and segment ...
If the source operand is a segment register (16 bits) and the operand size is 64-bits, a zero-extended value is pushed on the...
Read more >
Push Word, Doubleword or Quadword Onto the Stack
If the source operand is a segment register (16 bits) and the operand size is 64-bits, a zero-extended value is pushed on the...
Read more >
80386 Programmer's Reference Manual -- Section 17.2
a word register or memory operand used for instructions whose operand-size attribute is 16 bits. The word registers are: AX, BX, CX, DX,...
Read more >
X86-64 Instruction Encoding - OSDev Wiki
1 General Overview; 2 Registers; 3 Legacy Prefixes. 3.1 LOCK prefix; 3.2 REPNE/REPNZ, ... Operand-size and address-size override prefix.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found