问题
Whats the difference between using the built-in call and return instructions vs manually pushing and popping the stack and using jumps for functions?
回答1:
Functionally, if you do it correctly, nothing.
However it takes more instructions and/or registers to emulate call
/ret
using push
/pop
. Of course if you really wanted to take it to the extreme, you could also emulate push
/pop
using lea
and mov
:)
Also, current processors have specialized hardware to handle function calls for the purposes of branch prediction, which probably won't work for your alternate sequence so you will get performance penalty.
来源:https://stackoverflow.com/questions/29687203/x64-assembly-functions-call-return-vs-push-pop-jump