assembly - ARM Cortex-M0 load from SP with offset -


i have write arm cortex-m0 assembly code project , have run problem can't seem fix/figure out why it's happening. there's single instruction somehow makes program crash, if comment out, function returns, otherwise hangs.

here's line of code that's been ruining morning:

/* start address: preceded 8 backup, 3 state, 1 addr reg. */ ldr r0, [sp, #(4 * 11 + 4)] 

so, i'm trying accomplish load word that's got 48 byte offset current stack pointer value r0. arm instruction set manual has following ldr rt, [<rn | sp> {, #imm}]:

  • rt , rn must specify r0-r7.
  • imm must between 0 , 1020 , integer multiple of 4 ldr , str using sp base register
    • the computed address must divisible number of bytes in transaction, see address alignment.

clearly, 3 of these requirements met (the offset, 48, divisible 4, length of word in bytes).

trying find ways around this, had @ point following code:

add sp, #48 ldr r0, [sp] sub sp, #48 

unfortunately, doesn't work either. commenting out ldr instruction in segment above "fixes" (in sense function returns, of course result wrong).

the gcc version i'm using is:

gcc version 4.7.3 20121207 (release) [arm/embedded-4_7-branch revision 194305] (gnu tools arm embedded processors)

my build command is: arm-none-eabi-g++ -wall -std=c99 -mlittle-endian -mcpu=cortex-m0 -march=armv6-m -mthumb -ffunction-sections -fdata-sections -wl,--gc-sections -i -dstm32f0xx -duse_stdperiph_driver -os -mmd -mt build/release/assembly-code-arm.o -mf build/release/assembly-code.d -c -o build/release/assembly-code.o src/assembly-code.s

has got clue causing problem , how can fix it?


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -