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 - LinkMem2</title>
9</head>
10
11<body>
12
13<H1>RSO Sample Demo - LinkMem2</H1>
14
15<H2>Location</H2>
16<p><code>$REVOLUTION_SDK_ROOT/build/demos/rsodemo/LinkMem2</code></p>
17
18<H2>Overview</H2>
19<p>
20This is a demo program showing allocation of a dynamic module to external main memory (the <CODE>MEM2</CODE> area).<br>Module E (<code>e.rso</code>) allocated to external main memory and module F (<code>f.rso</code>) allocated to internal main memory are set to call functions from each other.
21</p>
22
23<H2>Description</H2>
24<p>
25Typically, branch instructions (<CODE>bx</CODE>) have only a 28-bit offset (&plusmn; 32 MB). Therefore, when a dynamic module is placed in external main memory (<CODE>MEM2</CODE>), functions in internal main memory (<CODE>MEM1</CODE>) cannot be accessed. To avoid this, instruct the compiler to use branching in the 32-bit absolute address using pragma.
26</p>
27<p>
28When module E is placed in <CODE>MEM2</CODE>, the static module function (such as <code>OSReport</code>) and a function from module F in <CODE>MEM1</CODE> (<code>IsFThere</code>) must be set as a branch using the 32-bit absolute address.<br>For this reason, the sample program will set those function as a branch of 32-bit absolute address when called within module E, as follows:
29</p>
30<TABLE border="1" width="100%">
31  <TBODY>
32    <TR>
33      <TD width="100%">
34      <PRE><CODE>
35// from e.c source
36#pragma section code_type &quot;.text&quot; data_mode=far_abs code_mode=far_abs
37#pragma section RX &quot;.init&quot; &quot;.init&quot; data_mode=far_abs code_mode=far_abs
38
39#include &lt;revolution.h&gt;
40
41#include &quot;f.h&quot;
42
43#pragma section code_type &quot;.text&quot; data_mode=far_abs code_mode=pc_rel
44#pragma section RX &quot;.init&quot; &quot;.init&quot; data_mode=far_abs code_mode=pc_rel
45</CODE></PRE>
46      </TD>
47    </TR>
48  </TBODY>
49</TABLE>
50<p>
51Also, because module F calls a module E function (<code>IsEThere</code>), they are set as follows:
52</p>
53<TABLE border="1" width="100%">
54  <TBODY>
55    <TR>
56      <TD width="100%">
57      <PRE><CODE>
58// from f.c source
59#pragma section code_type &quot;.text&quot; data_mode=far_abs code_mode=far_abs
60#pragma section RX &quot;.init&quot; &quot;.init&quot; data_mode=far_abs code_mode=far_abs
61
62#include &quot;e.h&quot;
63
64#pragma section code_type &quot;.text&quot; data_mode=far_abs code_mode=pc_rel
65#pragma section RX &quot;.init&quot; &quot;.init&quot; data_mode=far_abs code_mode=pc_rel
66</CODE></PRE>
67      </TD>
68    </TR>
69  </TBODY>
70</TABLE>
71<p>
72<B>Note</B> as of 2006/06/15:<br>Certain runtime codes may not be properly called in 32-bit codes in the release version.<br>As a temporary remedy, use_lmw_stmw pragma is currently applied to avoid the use of those run-time codes.<br>This is applied to modules placed in the external main memory.<br>
73
74This is used in <code>e.c</code> in the sample.<br><br>This is also true for the compile option <code>-use_lmw_stmw on</code>.<br>
75</p>
76<TABLE border="1" width="100%">
77  <TBODY>
78    <TR>
79      <TD width="100%">
80      <PRE><CODE>
81// from e.c source
82#pragma use_lmw_stmw on
83</CODE></PRE>
84      </TD>
85    </TR>
86  </TBODY>
87</TABLE>
88<H2>See Also</H2>
89<p>
90<a href="./demos.html">Sample List</a><br>
91<code><a href="../RSOListInit.html">RSOListInit</a></code>,
92<code><a href="../RSOLinkList.html">RSOLinkList</a></code>,
93<code><a href="../RSOUnLinkList.html">RSOUnLinkList</a></code>,
94<code><a href="../RSOFindExportSymbolAddr.html">RSOFindExportSymbolAddr</a></code>,
95<code><a href="../RSOIsImportSymbolResolvedAll.html">RSOIsImportSymbolResolvedAll</a></code>,
96</p>
97<H2>Revision History</H2>
98<p>2006/06/14 Initial version.</p>
99
100<hr><p>CONFIDENTIAL</p></body>
101</HTML>
102