RX65N + rlink.exe + #pragma inline_asm

I'm trying to assemble a tiny JMP instruction at a specific address in code flash.  I've set up a linker section at the address I want the code (normally a bootloader would reside here, instead I want this function) - it's just a branch to the PowerON_Reset_PC() function.  Basically I want the reset vector (0xFFFFFFFC) to point to this stub jump instruction, which jumps to PowerON_Reset_PC().

#pragma inline_asm sounded like a good way to implement this function, but for the life of me I can't get the linker to actually reserve instruction bytes in the section.


#pragma inline_asm PowerON_Reset_PC_jump

#pragma section BOOTLOADER

void PowerON_Reset_PC_jump(void)
        MOV.L #_PowerON_Reset_PC, R1
        JMP R1

#pragma section

I did not mark PowerON_Reset_PC_jump() with #pragma entry, just PowerON_Reset_PC().  The linker map output shows section BOOTLOADER has 0 bytes.  Is this because it's "inline" and nothing has called this function (therefore the two instructions haven't been inserted anywhere)?  Would I have to write a full assembly language source file to do what I'm trying to do?

I'll probably just stick with C, make PowerON_Reset_PC_jump() a C function, mark it with #pragma entry, and just call PowerON_Reset_PC().


Anthony Jenkins

  • Sorry, you did not understand inline assembler function.
    A inline assembler function is NOT a function like a C function. It is no function at all but looks only like a function.
    At the place, where this function is called in C code, the assembler code of this inline assembler function is inserted.
    Thus it cannot be placed in an own section.

    I don't understand why you use this inline assembler. You can define a pointer to a function, initialize this pointer with address 0xFFFFFFFC and use the pointer to jump to program start.

    typedef void (*function_ptr_t)(void);
    function_ptr_t JumpToStart;
    void PowerON_Reset_PC(void);

    JumpToStart = PowerON_Reset_PC;
  • Hello Anthony Jenkins,

    Was the Frank's reply useful for you? Is your issue solved now?

    Kind regards,
  • In reply to Sergey Sokol:

    I'm good, thanks!