1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
6<META http-equiv="Content-Style-Type" content="text/css">
7<LINK rel="stylesheet" type="text/css" href="../../CSS/revolution.css">
8<title>RSO Sample Demo LinkFar</title>
9</head>
10
11<body>
12
13<H1>RSO Sample Demo LinkFar</H1>
14
15<H2>Location</H2>
16<p><code>$REVOLUTION_SDK_ROOT/build/demos/rsodemo/LinkFar</code></p>
17
18<H2>Overview</H2>
19<p>
20Demo program showing allocation of a relocatable module to external main memory (MEM2 area).<br>Module E (<code>e.rso</code>) allocated to <CODE>MEM2</CODE> and module F (<code>f.rso</code>) allocated to <CODE>MEM1</CODE> are set to call functions from each other.
21</p>
22
23<H2>Description</H2>
24<p>
25Typically, the branch instructions (bx) have only the 28-bit offset (&plusmn;32MB). Therefore, when a relocatable module is placed in external main memory (<CODE>MEM2</CODE>), functions in internal main memory (<CODE>MEM1</CODE>) 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, and then link to that buffer.
26<p>
27When module G is placed in <CODE>MEM2</CODE>, the static module function (such as <code>OSReport</code>) and a function from module H in <CODE>MEM1</CODE> (<code>IsHThere</code>) must be set as a branch using the 32-bit absolute address.<br>In addition, because module H calls the module G function (<code>IsGThere</code>), this must also be made into a branch using 32-bit absolute address branching.
28</p>
29<p>
30In the sample, the above process occurs in the local functions <code>LinkFar</code> or <code>LinkFarMem2</code>.<br>Get the required buffer size with <code><a href="../RSOGetFarCodeSize.html">RSOGetFarCodeSize</a></code>, obtain the buffer, and then output the instruction code to the buffer with <code><a href="../RSOLinkFar.html">RSOLinkFar</a></code> to link to the buffer.
31</p>
32<p>
33<b>Note:</b> The buffer obtained should be in the same main memory (<CODE>MEM2</CODE> or <CODE>MEM1</CODE>) as the referencing module. <br>In addition, normally after linking, the code in the module is overwritten. Therefore, when using <code><a href="../RSOLinkList.html">RSOLinkListFixed</a></code>, proceed up to <code><a href="../RSOFixedLevel.html">RSO_FL_INTERNAL</a></code> at the release stage.
34</p>
35
36<H2>See Also</H2>
37<p>
38<a href="./demos.html">Sample List</a><br> <code><a href="../RSOLinkFar.html">RSOLinkFar</a></code>, <code><a href="../RSOGetFarCodeSize.html">RSOGetFarCodeSize</a></code>
39</p>
40<H2>Revision History</H2>
41<p>2006/09/25 Initial version.</p>
42
43<hr><p>CONFIDENTIAL</p></body>
44</HTML>
45