I am coding a small cortex M0+ bootloader. I have a inline assembly below that start the main application from the bootloader by loading the stack pointer and reset handler from application position in Flash.
#define FLASH_APP_START 0x1000
[...]
__asm(
// Update stack pointer from user code vector table
"LDR r0, =%0 \n"
"LDR r1, [r0] \n"
"MOV sp, r1 \n"
// Load user code reset handler and jump to the user code
"LDR r0, [r0, #4] \n"
"BX r0 \n"
:
: "X"(FLASH_APP_START)
:
);
When compiling this code I get the following error:
Error: bad expression -- `ldr r0,=#4096'
GCC add the # before the constant that should not be there. If I replace the first line by the following it works perfectly.
LDR r0, =0x1000
So the question is how could I use the defined constant ?
Thanks in advance for any help
#
, you could try%c0
. – David Wohlferd