Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 501
Scalahansolo Avatar asked Dec 04 '25 23:12

Scalahansolo


1 Answers

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.

like image 109
Carl Norum Avatar answered Dec 06 '25 19:12

Carl Norum