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

查看:65
本文介绍了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 是 任何加载/存储指令,所以机制并没有什么不同.不同的是,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 指令集中的push"只是 stmdb r13!, {rn, ..., rm}str rn, [sp, #-4]! 视情况而定,此类别名仅在作为 Thumb-2 一部分的统一汇编语言中引入.特定的推送/弹出指令确实出现在原始 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天全站免登陆