ARM Arch64 中的 PUSH {lr} 和 POP {lr} [英] PUSH {lr} and POP {lr} in ARM Arch64

查看:39
本文介绍了ARM Arch64 中的 PUSH {lr} 和 POP {lr}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ARM Arch64指令集中PUSH{lr}POP{lr}的等价指令是什么

What is the equivalent instruction for PUSH{lr} and POP{lr} in ARM Arch64 instruction set .

STR X30, [SP, #8] 正确吗?你能解释一下保持堆栈对齐的概念吗?我对 ARMv8 比较陌生,所以请原谅.

Is STR X30, [SP, #8] correct ? could you please explain the concept of maintaining stack alignment ? I am relatively new to ARMv8 so excuse me.

推荐答案

如果您要求 C 编译器从源代码生成汇编语言列表,您将看到它如何处理 ARMv8 堆栈上的数据推送.这可能不是唯一的方法,但 GCC 是这样做的:

If you ask the C compiler to generate an assembly language listing from your source, you'll see how it handles pushing data on the stack for ARMv8. This might not be the only way to do it, but GCC does it this way:

   sub  sp, sp, #32     \\ Open up some temp stack space
   stp  x19, x20, [sp]  \\ save 2 pairs of registers
   stp  x21, x30, [sp,#16]
 <your code>
   ldp  x19, x20, [sp]  \\ restore 2 pairs of registers
   ldp  x21, x30, [sp,#16]
   add  sp, sp, #32     \\ "free" the temp stack space

这篇关于ARM Arch64 中的 PUSH {lr} 和 POP {lr}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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