RSO Sample Demo LinkFar

Location

$REVOLUTION_SDK_ROOT/build/demos/rsodemo/LinkFar

Overview

Demo program showing allocation of a relocatable module to external main memory (MEM2 area).
Module E (e.rso) allocated to MEM2 and module F (f.rso) allocated to MEM1 are set to call functions from each other.

Description

Typically, the branch instructions (bx) have only the 28-bit offset (±32MB). Therefore, when a relocatable module is placed in external main memory (MEM2), functions in internal main memory (MEM1) cannot be accessed. One workaround is to obtain a buffer within the range that can be jumped to with a normal branch instruction (28 bits), output the instruction for the 32-bit absolute address branch to that buffer, then link to that buffer.

When module G is placed in MEM2, the static module function (such as OSReport) and a function from module H in MEM1 (IsHThere) must be set as a branch, using the 32-bit absolute address.
In addition, because module H calls the module G function (IsGThere), this must also be made into a branch using 32-bit absolute address branching.

In the sample, the above process occurs in the local functions LinkFar or LinkFarMem2.
Get the required buffer size with RSOGetFarCodeSize, obtain the buffer, then output the instruction code to the buffer with RSOLinkFar to link to the buffer.

Note: The buffer obtained should be in the same main memory (MEM2 or MEM1) as the referencing module.
In addition, normally after linking, the code in the module is overwritten. Therefore, when using RSOLinkListFixed, proceed up to RSO_FL_INTERNAL at the release stage.

See Also

Sample List
RSOLinkFar, RSOGetFarCodeSize,

Revision History

9/25/2006 Initial version.


CONFIDENTIAL