Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

This question is definitely a duplicate. Let me look around. Have you checked the docs ? They explain this stuff pretty well. You might want to translate to Intel-format assembly for easier lookup in those books, though. Carl Norum Feb 15, 2013 at 17:45 See also GAS syntax addressing mode syntax on wikibooks, and other links in the x86 tag wiki Peter Cordes Sep 23, 2017 at 7:44 See also the AT&T syntax tag wiki for more details on the syntax, and links to more docs. Peter Cordes Nov 18, 2017 at 17:43

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.

yes, but why especially uint8? all of ebx, eax and etc... registers are 32-bit, whether the information is lost in the upper three bytes? I'm asking because i have: leal 0x2004(%ebx), %eax but i see: leal 0x4(%ebx), %eax in debugger – 0xAX Feb 3, 2015 at 11:19 Because I want the eax*4 to be in increments of bytes, not 32-bit words. Notice that it's not dereferenced as a byte. – Carl Norum Feb 3, 2015 at 14:54