previous | start | next

Assembler for Array Access Formula

Assume the array address (i.e., address of a[0]) is

 -72(%ebp)
   

What assembler code would do this:

 a[3] = 100;
   

Answer: First the address of a[3] would be

  -60(%ebp)
   

So the compiler could generate

 movl $100, =60(%ebp)
   


previous | start | next