Keil Logo Arm Logo

Discussion Forum

jump to a location

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
robert francis
Posted
12-Jan-2007 09:18 GMT
Toolset
ARM
New! jump to a location

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

Read-Only
Author
Christoph Franck
Posted
12-Jan-2007 09:30 GMT
Toolset
ARM
New! RE: jump to a location

From the ARM Assembler Guide:

You can also load the program counter directly using data operation instructions.

Read-Only
Author
robert francis
Posted
12-Jan-2007 09:45 GMT
Toolset
ARM
New! RE: jump to a location

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

Read-Only
Author
Jonny Doin
Posted
26-Jan-2007 15:14 GMT
Toolset
ARM
New! RE: jump to a location

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.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.