C program setup – Zilog ZUSBOPTS User Manual

Page 352

Advertising
background image

Program Configurations

UM017105-0511

324

Zilog Developer Studio II – ZNEO™
User Manual

C Program Setup

The C program setup for Copy to RAM Program Configuration is similar to the Default
Program Configuration with some additional steps as described in this section.

The C-Compiler by default generates the executable program code under one unified seg-
ment named CODE. The CODE segment belongs to the EROM address space.

1. To set up this configuration, you must place the CODE segment in RAM at run time

and EROM at load time. Do this by adding the following linker commands in the

Additional Linker Directives

dialog box (see

Additional Directives

– see page 62):

change code=RAM /* Run time CODE is in RAM space */

copy code EROM /* Load time CODE is in EROM space */

define _low_code_copy = copy base of CODE

define _low_code = base of CODE

define _len_code = length of CODE

2. 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 CODE into RAM

;

LEA

R0,_low_code_copy

LEA

R1,_low_code

LD

R2,#_len_code+1

JP clab1

clab0:

LD.B R3,(R0++)

LD.B

(R1++),R3

clab1:

DJNZ R2,clab0

XREF

_low_code_copy:EROM

XREF

_len_code

XREF

_low_code:RAM

3. Finally, add your modified start-up module to your project by selecting the

Included

in Project

button in the

Objects and Libraries

page of the

Project Settings

dialog

box (see

C Start-up Module

– see page 66) and also add the modified source code file

to your project using the Add Files command from the

Project

menu.

Advertising
This manual is related to the following products: