Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.3k views
in Technique[技术] by (71.8m points)

assembly - ARM AArch64 stack management

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...