Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

66 prefix is ignored if REX prefix is used #10

Closed
nepx opened this issue Jun 3, 2023 · 1 comment
Closed

66 prefix is ignored if REX prefix is used #10

nepx opened this issue Jun 3, 2023 · 1 comment

Comments

@nepx
Copy link

nepx commented Jun 3, 2023

If the 66 prefix is followed by a REX prefix (even one sans REX.W), its effect appears to be negated.

0000000000000000 664101C0                        ADD R8D,EAX
0000000000000004 664103DC                        ADD EBX,R12D
0000000000000008 664189C0                        MOV R8D,EAX
000000000000000C 66418BC0                        MOV EAX,R8D
0000000000000010 6641C1C001                      ROL R8D,01
0000000000000015 664189C0                        MOV R8D,EAX

Expected output (objdump):

0:  66 41 01 c0             add    r8w,ax
4:  66 41 03 dc             add    bx,r12w
8:  66 41 89 c0             mov    r8w,ax
c:  66 41 8b c0             mov    ax,r8w
10: 66 41 c1 c0 01          rol    r8w,0x1
15: 66 41 89 c0             mov    r8w,ax 

Interestingly enough, if the REX prefix comes first, then everything works as expected:

0000000000000000 416601C0                        ADD R8W,AX
0000000000000004 416603DC                        ADD BX,R12W
0000000000000008 416689C0                        MOV R8W,AX
000000000000000C 41668BC0                        MOV AX,R8W
0000000000000010 4166C1C001                      ROL R8W,01
0000000000000015 416689C0                        MOV R8W,AX
Recoskie added a commit that referenced this issue Jun 5, 2023
@Recoskie
Copy link
Owner

Recoskie commented Jun 5, 2023

When the width bit was not set in the REX prefix, it defaulted to 32-bit. The update defaults to the current bit mode setting if the width bit is not set. Excellent work on spotting the issue, and thank you for reporting it.

@Recoskie Recoskie closed this as completed Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants