I have two registers w1 and w2 that I want to store on stack. I want to store the complete word w1 and half part of w2 into the stack. 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.
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."
I am able to replicate your error. So SP mod 16 must be 0.
Bus error (core dumped)