x64 assembly functions (call/return vs push/pop/jump)

瘦欲@ 提交于 2021-02-05 07:57:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!