How does “mov (%ebx,%eax,4),%eax” work? [duplicate]

无人久伴 提交于 2019-11-26 14:48:50

问题


Been working on an assembly assignment, and for the most part I understand assembly pretty well. Or well at least well enough for this assignment. But this mov statement is tripping me up. I would really appreciate if someone could just explain how this mov statement is manipulating the register values.

mov (%ebx,%eax,4),%eax

P.S. I wasnt able to find this specific type of mov statement by basic searches, so I appologize if I just missed it and am re asking questions.


回答1:


The complete memory addressing mode format in AT&T assembly is:

offset(base, index, width)

So for your case:

offset = 0
base = ebx
index = eax
width = 4

Meaning that the instruction is something like:

eax = *(uint32_t *)((uint8_t *)ebx + eax * 4 + 0)

In a C-like pseudocode.



来源:https://stackoverflow.com/questions/14900343/how-does-mov-ebx-eax-4-eax-work

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