This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How write relocatable c-function code

Hello. I want to relocate some function’s from Flash to a different position in PSRAM for a bootloader.

The problem is: Keil generates absolute jumps in the original function.
With relative jumps whould it work.

I have copied the original functions to the RAM like this:
------------
Flash function a at 0xC01000
------------
Flash function b at 0xC02000
------------
Flash function c at 0xC02800
->(to copy in RAM at 0xE00000)
------------

Now I copy the c-function from 0xC02800 to RAM at 0xE00000.

The Problem: In the function c is a IF cause,
that jumps to the end of the function at 0xC02872:

JMPA cc_UC, 0xC02872 ( +72 Bytes)

If i execute this copied function at the new position (E00000), the jump is located to E02872

JMPA cc_UC, 0xE02872 ( + 2872 Bytes)

and not to 0xE00072 ( + 72 Bytes).

Is there a compiler switch to generate relative jumps (JMPR, CALLR) instead to absolute Jumps (JMPA+,JMPA-,CALLA)?

Or is there a other solution for this problem?

(I need to use the HCompact model, to access all functions and the whole address-space for variables.)

Thanks

0