IA32 assembly code to Y86 assembly code: leal instruction

ε祈祈猫儿з 提交于 2019-12-24 15:19:18

问题


I am studying how to convert IA32 assembly code to Y86 assembly code, and I am stuck in the following instruction which is in IA32 code:

 leal(%edx, %eax), %eax

I cannot find the equivalent instructions for the Y86 code. I have though of two version as the following ones, but I am not sure which is right:

Version 1:

 mrmovl (%edx), %ebx
 mrmovl (%eax), %esi
 addl %ebx, %esi
 rrmovl %esi, 5eax

Version 2:

 addl %edx, %eax

Does anyone have a better idea?


回答1:


LEA doesn't access memory, it only does (address) arithmetic. As such your version #2 is correct.

Note that on x86 LEA doesn't affect flags, while ADD does. LEA also supports more complex effective address syntax, which is nevertheless quite straight-forward to transcribe to y86. For example,

leal offset(%eax, %ebx, 4), %edx

becomes:

rrmovl %ebx, %edx
addl %edx, %edx
addl %edx, %edx
addl %eax, %edx
pushl %eax           # save eax which used as temporary for adding the offset
irmovl $offset, %eax
addl %eax, %edx
popl %eax            # restore eax


来源:https://stackoverflow.com/questions/13545606/ia32-assembly-code-to-y86-assembly-code-leal-instruction

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!