This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Setting the stack and program counter.



Hi All,

I have written a bootloader to run in the TMS470M. if the bootloader decides that all is well, and the system should run application code, I would like to branch to the start of the application by loading the stack pointer, then program counter from the first 8 bytes of the application code.... i.e repicate the standard POR behaviour, and simplify the development of applications. my application will simply include standard startup code and vector table, which I can run as if it was a normal POR. The bootloader then loads the value at start of the application vector table and off it goes!

I'm not great at assembler, and I am struggling to find the correct instruction to load the SP and PC. Has anyone any example, or pointers? thanks. Phil

  • Hi Phil

                 No problem. The PC and SP are registers r15 and r13 respectively and you can use MOV, LDR etc instructions to load them. These instructions are typically in ARM mode.

    For eg.

        LDR PC, label

        .....

    label     .word <addr>

    You can also say SP in place of PC.

    The label should be within -4096 to 4095 bytes of the PC.

    You can look in this location for more info:

    http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/BABJFJBD.html

    You can also MOV into PC/SP or do other operations