Reputation: 493
what is the difference between following machine codes??
movl 8(%ebp), %ecx
leal 8(%ebp), %ecx
can someone explain this to me???
Upvotes: 0
Views: 313
Reputation: 33601
The first fetches the 32 bit value pointed to by 8(%ebp)
.
The latter computes the flat address.
Thus, in C, given int x = 0;
and it is located at 8(%ebp)
(i.e. x
is in the stack frame of the function):
The first is int y = x;
The latter is int *z = &x;
In machine code [for most/many architectures, such as x86
--but not all (e.g. mc68000
)] registers are the same regardless of whether they contain a value or address.
Upvotes: 2