can i jump from a bootloader designed by me to an application program by changing the ProgramCounter .. i have an address location in a variable ..
mov pc, addr .. is this possible or any other options
... there is no return from application to bootloader program.. plz help me
From the ARM Assembler Guide:
You can also load the program counter directly using data operation instructions.
plz help me .. how can i do that .. when i used the move function it returned error i am using GNU compiler
asm("MOV PC,=ADDR"); returns error as shifting register expected no error when asm("MOV PC,0x8000");
how can i jump to code block whose address is in global variable
i have also tried LDR R0 and BX r0 as in startup.s
To jump to a function whose address is in a global var, you don't need to go low-level. Declare your var as a function pointer:
// declare pmain var as a function pointer to a int(void) function int (*pmain)(void); // do whatever you do, and load the target address in pmain pmain = (int (*)(void)) 0x40000000; // cast it to the func ptr type // ... // now call the code pointed by pmain. pmain(); // pmain will never return ...
This produces code like:
0x00000250 E3A00101 MOV R0,#0x40000000 0x00000254 E1A0E00F MOV R14,PC 0x00000258 E12FFF10 BX R0
That is only one extra instruction from doing MOV PC, R0, generally irrelevant in a ARM processor.
Another point in your post is to optimize for a function that never returns. The RVCT has the function qualifier __declspec(noreturn) to tell the compiler that it is OK to remove the function return code from the target function.