LEA or ADD instruction?

后端 未结 5 744
天命终不由人
天命终不由人 2020-12-04 11:07

When I\'m handwriting assembly, I generally choose the form

lea eax, [eax+4]

Over the form..

add eax, 4

I

5条回答
  •  悲&欢浪女
    2020-12-04 11:28

    LEA isn't faster than ADD instruction the execution speed is the same.

    But LEA sometimes offer more than ADD. If we need simple and fast addition/multiplication in combination with second register than LEA can speed-up program execution. From the other side the LEA doesn't affect to the CPU flags so there is no overflow detection possibility.

提交回复
热议问题