1

Is doing LEA RDI, [RBP - 8] the same as doing

   MOV RDI, RBP
   SUB RDI, 8
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 4
    Yes it is, except for the effect on flags. – Jester Feb 06 '21 at 20:14
  • 4
    It produces the same result, but using lea takes 3 fewer bytes. There may also be a (microscopic) difference in performance, plus the effect on the flags. – David Wohlferd Feb 06 '21 at 20:34
  • Basically yes, LEA is just a shift-and-add instruction. One of the few math instructions that don't affect FLAGS at all (others including `not` and `loop`), but if you don't need an exact drop-in replacement then yeah. [Using LEA on values that aren't addresses / pointers?](https://stackoverflow.com/a/46597375) – Peter Cordes Feb 06 '21 at 22:48

0 Answers0