ARM AArch64 stack management

[亡魂溺海] 提交于 2021-02-05 08:06:25

问题


Is there no ability to have a 64 bit stack for ARMv8? I understand there is no push and pop instructions on AArch64 so is stack management left to AArch32 for parameter passing and such? How can we pass the 48 bit addresses? I'm overall confused how function calls will work when operating in AArch64.


回答1:


Much like in 32-bit*, SP is a valid base register for any load/store instruction, so the mechanics aren't all that different. What is different is that SP is no longer a general-purpose register you can do whatever you want with, you don't have variable load/store-multiple operations any more, and there are no programmer-friendly aliases. Thus a typical "push" would be:

stp xn, xm, [sp, #-16]!

Note that you should generally use stp/ldp in favour of str/ldr in order to maintain alignment when operating on the stack (and especially when you have the hardware alignment checking turned on) - if you only have one register you care about, push/pop xzr as the other to fill the gap.


* Remember that e.g. "push" in the ARM instruction set is just an assembler alias for stmdb r13!, {rn, ..., rm} or str rn, [sp, #-4]! as appropriate, and such aliases were only introduced with the unified assembly language as part of Thumb-2. Specific push/pop instructions did appear in original 16-bit Thumb, as SP can't be encoded in the normal load/store ops there which only operate on low registers.



来源:https://stackoverflow.com/questions/31346886/arm-aarch64-stack-management

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