malith vitha
malith vitha

Reputation: 493

LEAL and MOVL in machine instruction

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

Answers (1)

Craig Estey
Craig Estey

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

Related Questions