Aliging ARM汇编堆栈指针8个字节的4个字节 [英] Aliging a Stack pointer 8 byte from 4 byte in ARM assembly

查看:645
本文介绍了Aliging ARM汇编堆栈指针8个字节的4个字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何调整栈指针,以8字节,现在是在ARM。至于按我的理解堆栈指针对准4字节,如果它指向像为0x4,0x8,0x12一些地址0x16等4个字节对齐。

How do I align a stack pointer to 8 byte which is now 4 byte aligned in ARM .As per my understanding stack pointer is 4 byte aligned if it points to some address like 0x4 ,0x8,0x12 and 0x16 so on.

所以,aliging栈指针,以8字节意味着它应该指向像0x8中,0x16,0X24和0x32等地址。

So ,aliging a stack pointer to 8 byte means it should point to addresses like 0x8 ,0x16 ,0x24 and 0x32 and so on.

现在我该怎么办对齐4字节堆栈指针的8字节对齐的指针?

Now how Do I aligned 4 byte stack pointer to 8 byte aligned pointer ?

推荐答案

不要试图调整 SP 手动自己,而不是多一个寄存器获取对齐。例如,而不是

Don't try to align sp manually yourself, instead push one more register to get alignment. For example instead of

push {r3, r4, lr}

增加一个寄存器列表以获得对齐8轻松。

add one more register to the list to get alignment to 8 easily.

push {r1, r3, r4, lr}

这可能会觉得像额外的内存访问,但总体缓存比本地字长较宽位向量工作。

This may feel like extra memory access but in general caches works with wider bit vectors than native word sizes.

另外要注意的是也,你不必强迫自己获得栈对齐的权利,如果你不是做外部呼叫或接收。所以,如果你已经关闭箱汇编程序不使外部世界来电或者收到的,你可以打破栈对齐,只要它不咬你自己的生活负荷

Another note is also, you don't need to force yourself to get stack alignment right if you are not doing external calls or receiving. So if you have closed box assembly routine which doesn't make calls to external world or receive some, you can live with broken stack alignment as long as it doesn't bite your own loadings.

这篇关于Aliging ARM汇编堆栈指针8个字节的4个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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