> Does saying 4(%ebp) mean the same as %ebp?

No.  4(%ebp) means to take the value of %ebp, add 4 to it, and then use
that as a memory address to load the real value from.

> For example, would the following two lines mean the same thing?
>
> movl 4(%ebp), %eax
>
> ...or....
>
> movl %ebp, %eax

Let's say that %ebp has the value of 5 in it.  The first one will add 4 to
%ebp, giving 9, and then look in the computer at memory address number 9
and load whatever is in there into %eax (note that this would actually
kill your application because that is out-of-bounds, but this is just an
example ;] ).

The second one would simply load the number 5 into %eax, without ever
looking into memory at all.

> If %esp = %ebp, then could you also use:
>
> movl 4(%ebp), %eax
>
> ...or...
>
> popl %eax
>
> ..or...
>
> movl %ebp, %eax

No.  Besides the issue I mentioned before, popl has additional
significance: It modified %esp.

So pushl %eax is equivalent to:
subl $4, %esp
movl %eax, (%esp)

and popl %eax is equivalent to:
movl (%esp), %eax
addl $4, %esp

Hope that helps.

Jon


_______________________________________________
Pgubook-readers mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/pgubook-readers

Reply via email to