M configuration discussed in the, Special case: partial, Copy to ram – Zilog ZUSBOPTS User Manual
Page 353: In the, Special, Case: partial copy to ram

UM017105-0511
Program Configurations
Zilog Developer Studio II – ZNEO™
User Manual
325
Special Case: Partial Copy to RAM
A special case of this configuration is when you want to copy program code from just one
C source file into RAM, while retaining the rest of the code in EROM. This allows you to
investigate whether there might be power or speed savings to be realized by partitioning
your application in this way. Perform the following steps:
1. Select the
Distinct Code Segment for Each Module
checkbox in the
Advanced
page in the
Project Settings
dialog box (see
) to direct the C-Compiler to
generate different code segment names for each file.
2. Add the linker commands to place the particular segment in RAM at run time and
EROM at load time.
For example, to copy the code for
main.c
to RAM, add the following linker com-
mands in the
Additional Linker Directives
dialog box (see
change main_TEXT=RAM /* Run time main_TEXT is in RAM space */
copy main_TEXT EROM /* Load time main_TEXT is in EROM space */
define _low_main_copy = copy base of main_TEXT
define _low_main = base of main_TEXT
define _len_main = length of main_TEXT
3. The linker COPY directive only designates the load addresses and the run-time
addresses for the segment. The actual copying of the segment must be performed by
the start-up code. For example, if you are using the small model, copy and modify the
C startup provided in the installation under
src\boot\common\startupexs.asm
,
rewriting the relevant section as follows:
;
; Copy main_TEXT into ERAM
;
LEA
R0,_low_main_copy
LEA
R1,_low_main
LD
R2,#_len_main+1
JP mlab1
mlab0:
LD.B R3,(R0++)
LD.B
(R1++),R3
mlab1:
DJNZ R2,mlab0
XREF
_low_main_copy:EROM
XREF
_len_main
XREF
_low_main:RAM