Skip to content

Conversation

hainest
Copy link
Contributor

@hainest hainest commented Sep 22, 2025

These should have been part of
#2578

There are two bugs in 64-bit mode that can't be fixed here:

  1. retf (0xcb) is decoded as X86_LRETL instead of X86_LRETQ
  2. retf (0xca iw16) is decoded as X86_LRETIL instead of X86_LRETIQ

In 16-bit mode, Zydis and xed use 'esp' instead of 'sp' for all 'ret*' instructions. I've opted not to follow that since it makes no sense to have a 32-bit register present in a 16-bit context. I'll submit a bug report to Zydis and see what they say.

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

Update the read/written registers for ret, iret, retf, and iretf. Include complete testing of all instruction permutations.

Test plan

Tests are included.

Copy link
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@Rot127
Copy link
Collaborator

Rot127 commented Sep 30, 2025

Please rebase

@Rot127
Copy link
Collaborator

Rot127 commented Oct 2, 2025

One more time please

These should have been part of
capstone-engine#2578

There are two bugs in 64-bit mode that can't be fixed here:

1. retf (0xcb) is decoded as X86_LRETL instead of X86_LRETQ
2. retf <imm> (0xca iw16) is decoded as X86_LRETIL instead of X86_LRETIQ

In 16-bit mode, Zydis and xed use 'esp' instead of 'sp' for all 'ret*'
instructions. I've opted not to follow that since it makes no sense to
have a 32-bit register present in a 16-bit context. I'll submit a bug
report to Zydis and see what they say.
@hainest
Copy link
Contributor Author

hainest commented Oct 2, 2025

One more time please

Updated. :)

@Rot127 Rot127 merged commit ddf472b into capstone-engine:next Oct 2, 2025
22 checks passed
@hainest hainest deleted the thaines/x86_ret branch October 2, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants