What is macro RELOC (defined in romMipsInit.s) used for? - VxWorks

This is a discussion on What is macro RELOC (defined in romMipsInit.s) used for? - VxWorks ; Hi, all I'm working on BSP to support a board based on a MIPS cpu. And I'm somewhat comfused by this RELOC macro, I guess it is for getting relative offset to "ra" register. However, I can't understand the need ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: What is macro RELOC (defined in romMipsInit.s) used for?

  1. What is macro RELOC (defined in romMipsInit.s) used for?

    Hi, all

    I'm working on BSP to support a board based on a MIPS cpu.

    And I'm somewhat comfused by this RELOC macro, I guess it is for
    getting relative offset to "ra" register. However, I can't understand
    the need of adding "ra" to "toreg" (addu toreg, ra).

    Why?

    Thanks in advance!

    #ifndef RELOC
    #define RELOC(toreg,address) \
    bal 9f; \
    9:; \
    la toreg,address; \
    addu toreg,ra; \
    la ra,9b; \
    subu toreg,ra
    #endif


  2. Re: What is macro RELOC (defined in romMipsInit.s) used for?

    I mean why add "ra" at first then subtract it later?

    unicell wrote:

    > Hi, all
    >
    > I'm working on BSP to support a board based on a MIPS cpu.
    >
    > And I'm somewhat comfused by this RELOC macro, I guess it is for
    > getting relative offset to "ra" register. However, I can't understand
    > the need of adding "ra" to "toreg" (addu toreg, ra).
    >
    > Why?
    >
    > Thanks in advance!
    >
    > #ifndef RELOC
    > #define RELOC(toreg,address) \
    > bal 9f; \
    > 9:; \
    > la toreg,address; \
    > addu toreg,ra; \
    > la ra,9b; \
    > subu toreg,ra
    > #endif



+ Reply to Thread