movl / leal, difference in this case

This question already has an answer here:

  • What's the purpose of the LEA instruction? 14 answers

  • They are not similar.

    mov ebx, (esp)
    lea ecx, (esp)
    

    (in regular assembler, not gas style). The first loads ebx with the contents of esp . The second loads ecx with esp itself. The similar "regular" expression would have been

    mov ecx, esp
    

    but using lea you can immediately add a constant, a register, or both to ecx . Eg,

    lea ecx, (esp+4*eax+10h)
    

    sets ecx to esp + 4*eax + 10h -- using 'mov', you would have to add these with more instructions.

    链接地址: http://www.djcxy.com/p/72376.html

    上一篇: movl和leal指令之间的区别

    下一篇: movl / leal,在这种情况下的区别