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

Fix #16433 - Use MOV opcode B8+ for MOV r64, <0x80000000 to 0xffffffff> #16572

Merged
merged 1 commit into from
Apr 13, 2020

Conversation

kazarmy
Copy link
Contributor

@kazarmy kazarmy commented Apr 13, 2020

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the documentation and the radare2 book with the relevant information (if needed)

Detailed description

I've confirmed #16433 (comment) (including the nasm rax -> eax bug) and thus this pr makes the x86_64 assembler use the MOV B8+ encoding (MOV r64, imm64) when the immediate is between 0x80000000 and 0xffffffff for both:

  1. Consistency with GNU assembler.
  2. It actually does seem to be the expected encoding.

This does mean that mov eax, 0xffffffff and mov rax, 0xffffffff will have very different semantics.

Test plan

GitHub Actions and AppVeyor are green.

Closing issues

Closes #16433.

@radare
Copy link
Collaborator

radare commented Apr 13, 2020

Please resolve the conflict, the tests has been moved to test/db

@radare radare added this to the 4.4.0 - pangolin milestone Apr 13, 2020
((!(op->operands[0].type & OT_QWORD) && (op->operands[1].type & OT_QWORD) &&
immediate < UT32_MAX) ||
((op->operands[0].type & OT_QWORD) &&
(immediate <= ST32_MAX || immediate >= 0xffffffff80000000 /* -0x80000000 */)))) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

use LL suffix on those 64bit numbers, some compilers may complain

Copy link
Collaborator

@radare radare left a comment

Choose a reason for hiding this comment

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

move the test pls

…0xffffffff> radareorg#16572 ##asm

Detailed description

I've confirmed radareorg#16433 (comment) (including the nasm rax -> eax bug) and thus this pr
makes the x86_64 assembler use the MOV B8+ encoding (MOV r64, imm64) when the immediate
is between 0x80000000 and 0xffffffff for both:

Consistency with GNU assembler.  It actually does seem to be the expected encoding.
This does mean that mov eax, 0xffffffff and mov rax, 0xffffffff will have very different semantics.
@radare
Copy link
Collaborator

radare commented Apr 13, 2020

i did it

@radare radare merged commit a43831b into radareorg:master Apr 13, 2020
@kazarmy
Copy link
Contributor Author

kazarmy commented Apr 13, 2020

thanks!

Emi1305 pushed a commit to Emi1305/radare2 that referenced this pull request Jul 12, 2020
…0xffffffff> radareorg#16572 ##asm

Detailed description

I've confirmed radareorg#16433 (comment) (including the nasm rax -> eax bug) and thus this pr
makes the x86_64 assembler use the MOV B8+ encoding (MOV r64, imm64) when the immediate
is between 0x80000000 and 0xffffffff for both:

Consistency with GNU assembler.  It actually does seem to be the expected encoding.
This does mean that mov eax, 0xffffffff and mov rax, 0xffffffff will have very different semantics.
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

Successfully merging this pull request may close these issues.

rasm2 -b64 'mov rax, 0xdeadbeef' | rasm2 -d -b64 - doesn't round trip.
2 participants