mov instructions & registers - confusion !

I am reading "Computer Systems: A Programmer Perspective", chapter 3 explains mov instruction, and explanation give in a book confuses me.

give a function (page 142 1's edition)

int exchange( int *xp, int y)
{
    int x = *xp;
    *xp = y;
    return x;
} 

Assembly code of function's body

movl 8(%ebp), %eax  //Get xp  
movl 12(%ebp), %edx //Get y  
movl (%eax), %ecx   //Get x at *xp  
movl %edx, (%eax)   //Store y at *xp  
movl %ecx, %eax     //Set x as return value

What confuses me, is what is going to be stored, and where
Here is how I understand this:

movl 8(%ebp), %eax  //Get xp  

CPU moves +8 bytes up the stack(from frame pointer %ebp), takes the value stored at that location, and stores this value at the register %eax(to emphasis - stores the value, not the address)

I am right ? Thanks !

10
задан newprint 4 November 2010 в 03:05
поделиться