This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unaligned access in stmfd instruction

I am trying to understand the unaligned access in the arm instruction. I tried to store a register into an unaligned stack pointer using the instruction stmfd. I was expecting a segmentation fault but the program ran without any error. Is the instruction itself expecting the memory to be aligned or if we properly set the stack then is it expected to work even if it is unaligned?

Below is the disassembly of the code:

0x00010450 <+0>: push {r12, lr}
0x00010454 <+4>: ldr r0, [pc, #36] ; 0x10480 <main+48>
0x00010458 <+8>: mov r1, #65 ; 0x41
0x0001045c <+12>: mov r2, #66 ; 0x42
0x00010460 <+16>: mov r3, #67 ; 0x43
0x00010464 <+20>: mov r4, #68 ; 0x44
0x00010468 <+24>: sub sp, sp, #1
0x0001046c <+28>: stmfd sp!, {r4}
0x00010470 <+32>: bl 0x102c8
0x00010474 <+36>: add sp, sp, #5
0x00010478 <+40>: mov r0, #0
0x0001047c <+44>: pop {r12, pc}
0x00010480 <+48>: andeq r0, r1, r0, lsr r4
0x00010484 <+52>: nop ; (mov r0, r0)
0x00010488 <+56>: nop ; (mov r0, r0)
0x0001048c <+60>: nop ; (mov r0, r0)

at the address 0x0001046c, the value in SP is [sp             0xbefff247].

Ran on raspberry pi under qemu with cpu=arm1176