0
  1. movq %src, %dest

  2. leaq (%src), %dest

I think the two instructions fulfill the same purpose, copying the value of src to dest. I want to know if I'm right or if not, what the difference is between the two.

Let src = 0x100 and 0x100 = 3.

This is what I thought. The first instruction 1. movq will copy 0x100 to dest. The second instruction 2. leaq will copy the reference of 3 which is 0x100 to dest.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Hanrabong
  • 35
  • 4
  • Yes, you are correct. The two insructions with these operands do the same thing. – fuz Apr 11 '22 at 12:04
  • One difference is performance: LEA won't be zero latency, but MOV can be. Not of course zero cost, though: there are always throughput costs for any instruction. ([Can x86's MOV really be "free"? Why can't I reproduce this at all?](https://stackoverflow.com/a/44193770)). – Peter Cordes Apr 11 '22 at 16:50
  • See also [x86-64 instruction set, AT&T syntax, confusion regarding lea and brackets](https://stackoverflow.com/q/61304524) for other LEA examples. – Peter Cordes Apr 13 '22 at 06:37

0 Answers0