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

x86 Translation question 1 #38

Closed
nimrodpar opened this issue Aug 18, 2016 · 2 comments
Closed

x86 Translation question 1 #38

nimrodpar opened this issue Aug 18, 2016 · 2 comments

Comments

@nimrodpar
Copy link

Hi again.

Quick question regarding the translation of some x86 command:

This:
'xor esi, esi'
gets translated into:

   22 | t27 = 32Uto64(0x00000000)
   23 | PUT(rsi) = t27
   24 | t29 = GET:I64(rsi)
   25 | t28 = 64to32(t29)
   26 | t3 = t28
   27 | t31 = GET:I64(rsi)
   28 | t30 = 64to32(t31)
   29 | t2 = t30
   30 | t1 = Xor32(t3,t2)
   31 | PUT(cc_op) = 0x0000000000000013
   32 | t32 = 32Uto64(t1)
   33 | PUT(cc_dep1) = t32
   34 | PUT(cc_dep2) = 0x0000000000000000
   35 | t33 = 32Uto64(t1)
   36 | PUT(rsi) = t33
   37 | PUT(rip) = 0x00000000004098ca

Which is fine except for the first 2 commands that set 0 into rsi (i guess that is what happens, but it's modeled in the rest of the block and kinda makes the actual Xoring wrong)

Any insights as to why this happens?

@zardus
Copy link
Member

zardus commented Aug 26, 2016

VEX works in mysterious ways... My guess is that it does this to make it easier for later optimization steps, but we'd have to look at the VEX source to make sure.

@rhelmot
Copy link
Member

rhelmot commented Jan 31, 2017

Also, you can turn on IR optimization, which will hopefully make everything cleaner.

@rhelmot rhelmot closed this as completed Jan 31, 2017
shaymargolis pushed a commit to shaymargolis/pyvex that referenced this issue Jul 16, 2024
* amd64_toIR: Decode endbr.

* Decode endbr32/64 for amd64/x86

Co-authored-by: Audrey Dutcher <audrey@rhelmot.io>
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

3 participants