“enter” vs “push ebp; mov ebp, esp; sub esp, imm” and “leave” vs “mov esp, ebp; pop ebp”

前端 未结 3 1926
迷失自我
迷失自我 2020-11-27 17:14

What is the difference between the enter and

push ebp
mov  ebp, esp
sub  esp, imm

instructions? Is there a performence differe

3条回答
  •  温柔的废话
    2020-11-27 17:19

    There is no real speed advantage using either of them, though the long method will probably run better due to the fact CPU's these days are more 'optimized' to the shorter simpler instructions that are more generic in use (plus it allows saturation of the execution ports if your lucky).

    The advantage of LEAVE (which is still used, just see the windows dlls) is that its smaller than manually tearing down a stack frame, this helps a lot when your space is limited.

    The Intel instruction manuals (volume 2A to be precise) will have more nitty gritty details on the instructions, so should Dr Agner Fogs Optimization manuals

提交回复
热议问题