Why is there no companion instruction to leave on the x86? That way,

pushl   %ebp
movl    %esp,%ebp
pushl   $3
popl    %eax
leave
ret

could become:

enter #or something
pushl   $3
popl    %eax
leave
ret

Isn't that just faster in general?

有帮助吗?

解决方案

In fact, there is an enter instruction. As to why it's not seeing much use, "Intel® 64 and IA-32 Architectures Optimization Reference Manual" offers a hint:

Assembly/ Compiler Coding Rule 32. (MH impact, M generality) Use push/pop to manage stack space and address adjustments between function calls/returns instead of enter/leave. Using enter instruction with non-zero immediates can experience significant delays in the pipeline in addition to misprediction.

其他提示

There is indeed a matching ENTER (Art of Assembly Language) instruction. It's seldom used however, because it is very slow, as explained in the link.

There is enter, for some processors.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top