ARM AArch64堆栈管理 [英] ARM AArch64 stack management

查看:137
本文介绍了ARM AArch64堆栈管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ARMv8不能具有64位堆栈吗?我知道AArch64上没有推入和弹出指令,所以堆栈管理是否留给AArch32进行参数传递等等?我们如何传递48位地址?总体而言,我很困惑在AArch64中进行操作时函数调用将如何工作.

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.

推荐答案

与32位 * 相似,SP是

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]!

请注意,为了维护,通常应使用 stp / ldp 代替 str / ldr 在堆栈上进行操作时进行对齐(特别是在打开硬件对齐检查时)-如果您只关心一个寄存器,则将 xzr 推入/弹出作为另一个,以填补空白.

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.

*请记住,例如ARM指令集中的推"只是 stmdb r13!,{rn,...,rm} str rn,[sp,#-4]的汇编程序别名!/code>,这样的别名仅作为统一的汇编语言作为Thumb-2的一部分引入.特定的推入/弹出指令 did 出现在原始的16位Thumb中,因为SP不能在仅在低位寄存器上运行的普通加载/存储操作中进行编码.

* 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.

这篇关于ARM AArch64堆栈管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆