Need Help. Change code for arm-none-eabi-gcc

Post your cool example code here.
Post Reply
alex
Posts: 19
Joined: Tue Jul 28, 2015 2:12 am

Need Help. Change code for arm-none-eabi-gcc

Post by alex » Mon Aug 29, 2016 7:38 am

How to make this code suit for arm-none-eabi-gcc, thanks.
I know nothing about assembly language.

Code: Select all

__asm void jump_to_sram(void)
{
   LDR   R0,=0x20000000  ; starting address of program in SRAM.
   LDR   R1,[R0]  ; Get initial MSP value
   MOV   SP, R1  ; Set SP value
   LDR   R1,[R0, #4] ; Get initial PC value
   BX R1
}

edogaldo
Posts: 255
Joined: Fri Jun 03, 2016 8:19 am

Re: Need Help. Change code for arm-none-eabi-gcc

Post by edogaldo » Mon Aug 29, 2016 11:54 am

alex wrote:How to make this code suit for arm-none-eabi-gcc, thanks.
I know nothing about assembly language.

Code: Select all

__asm void jump_to_sram(void)
{
   LDR   R0,=0x20000000  ; starting address of program in SRAM.
   LDR   R1,[R0]  ; Get initial MSP value
   MOV   SP, R1  ; Set SP value
   LDR   R1,[R0, #4] ; Get initial PC value
   BX R1
}
Try this:

Code: Select all

void jump_to_sram(void)
{
   asm ("LDR   R0,=0x20000000\n\t"  // starting address of program in SRAM.
   "LDR   R1,[R0]\n\t"  // Get initial MSP value
   "MOV   SP, R1\n\t"  // Set SP value
   "LDR   R1,[R0, #4]\n\t"  // Get initial PC value
   "BX R1");
}

alex
Posts: 19
Joined: Tue Jul 28, 2015 2:12 am

Re: Need Help. Change code for arm-none-eabi-gcc

Post by alex » Tue Aug 30, 2016 12:59 pm

edogaldo wrote:
alex wrote:How to make this code suit for arm-none-eabi-gcc, thanks.
Try this:

Code: Select all

void jump_to_sram(void)
{
   asm ("LDR   R0,=0x20000000\n\t"  // starting address of program in SRAM.
   "LDR   R1,[R0]\n\t"  // Get initial MSP value
   "MOV   SP, R1\n\t"  // Set SP value
   "LDR   R1,[R0, #4]\n\t"  // Get initial PC value
   "BX R1");
}
Thanks a lot.

Post Reply