assembly - "enter" vs "push ebp; mov ebp, esp; sub esp, imm" and "leave" vs "mov esp, ebp; pop ebp" -
what difference between enter
and
push ebp mov ebp, esp sub esp, imm
instructions? there performence difference? if so, faster , why compilers use latter?
similarily leave
and
mov esp, ebp pop ebp
instructions.
there performance difference, enter
. on modern processors decodes 10 20 µops, while 3 instruction sequence 4 6, depending on architecture. details consult agner fog's instruction tables.
additionally enter
instruction has quite high latency, example 8 clocks on core2, compared 3 clocks dependency chain of 3 instruction sequence.
furthermore 3 instruction sequence may spread out compiler scheduling purposes, depending on surrounding code of course, allow more parallel execution of instructions.
Comments
Post a Comment