简体   繁体   English

在armv8架构中将半字值存储到堆栈内存中时出现总线错误?

[英]BUS Error while storing halfword value into stack memory in armv8 architecture?

I have two registers w1 and w2 that I want to store on stack.我有两个寄存器 w1 和 w2,我想将它们存储在堆栈中。 I want to store the complete word w1 and half part of w2 into the stack.我想将完整的单词 w1 和 w2 的一半存储到堆栈中。 Here is my implementation:这是我的实现:

STR w1, [sp, #-8]!
STRH w2, [sp, #-8]!

On compilation the first instruction runs fine but the second instruction throws a bus error.在编译时,第一条指令运行良好,但第二条指令引发总线错误。 I know this is some alignment issue but I am not able to properly understand why is this happening?我知道这是一些对齐问题,但我无法正确理解为什么会发生这种情况?

I am compiling for ARMv8(64-bit) architecture.我正在编译 ARMv8(64 位)架构。

According to the ARMv8 Instruction Set Overview, among other documents, "... if SP is used as the base register then the value of the stack pointer prior to adding any offset must be quadword (16 byte) aligned, or else a stack alignment exception will be generated."根据 ARMv8 指令集概述,在其他文件中,“...如果 SP 用作基址寄存器,则在添加任何偏移量之前堆栈指针的值必须是四字(16 字节)对齐,否则堆栈对齐将产生异常。”

I am able to replicate your error.我能够复制您的错误。 So SP mod 16 must be 0.所以 SP mod 16 必须是 0。

Bus error (core dumped)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM