0

what is the difference between following machine codes??

movl 8(%ebp), %ecx

leal 8(%ebp), %ecx

can someone explain this to me???

malith vitha
  • 473
  • 4
  • 4
  • Possible duplicate of [What's the purpose of the LEA instruction?](https://stackoverflow.com/questions/1658294/whats-the-purpose-of-the-lea-instruction) – 273K Jan 06 '19 at 04:40
  • You should specify which CPU type you are using — I'd guess it is an Intel chip of some sort, but you should include the information in the question. It is also not clear why you think 'assembler' or 'machine code' questions should be tagged with C — it isn't directly C code in any meaningful sense. – Jonathan Leffler Jan 06 '19 at 04:44

1 Answers1

2

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.

Craig Estey
  • 30,627
  • 4
  • 24
  • 48