What is the meaning of lea 0x0(%esi),%esi

我怕爱的太早我们不能终老 提交于 2019-12-10 03:34:12

问题


lea    0x0(%esi),%esi

I believe it has no result and is simply filling space. Is this the case?


回答1:


Its a NOP. It adds the contents of %esi and 0x0, and puts the result in %esi. Somebody either has a clumsy code generator or needs to fill N bytes, where this instruction is the right size.

LEA instructions execute quite fast (typically 1 clock), so this is a lot better than N nops.

The x86 being as quirky as it is, has a variety of instructions that effectively don't do anything but fill differing numbers of bytes. You may find other useless instructions of different lengths. You tend to find instructions that are long but execute in 1 clock or less.

The AMD x86-64 manual has some suggestions as to what should be used for NOPs; they suggest one of the prefix opcodes repeated a number of times before an actual NOP, IIRC. Such prefix opcodes are consumed very quickly by the instruction fetch engine; mostly their cost is hidden in instruction pre-fetch, and not in instruction execution time.



来源:https://stackoverflow.com/questions/10505690/what-is-the-meaning-of-lea-0x0esi-esi

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