beautypg.com

Zilog ZUSBOPTS User Manual

Page 87

background image

UM017105-0511

Menu Bar

Zilog Developer Studio II – ZNEO™

User Manual

59

All calls to

printf()

and

sprintf()

must use string literals, rather than

char*

variables, as parameters. For example, the following code allows the compiler to
reduce the code size:

sprintf ("Timer will be reset in %d seconds", reset_time);

But code such as the following results in larger code:

char * timerWarningMessage;

...

sprintf (timerWarningMessage, reset_time);

The functions

vprintf()

and

vsprintf()

cannot be used, even if the format string

is a string literal.

If the

Generate Printfs Inline

checkbox is selected and these conditions are not met, the

compiler warns you that the code size cannot be reduced. In this case, the compiler gener-
ates correct code, and the execution is significantly faster than with normal

printf

calls.

However, there is a net increase in code size because the generated inline calls to lower
level functions require more space with no compensating savings from removing the top-
level functions.

In addition, an application that makes over 100 separate calls of

printf

or

sprintf

might result in larger code size with the

Generate Printfs Inline

checkbox selected

because of the cumulative effect of all of the inline calls. The compiler cannot warn about
this situation. If in doubt, simply compile the application both ways and compare the
resulting code sizes.

The

Generate Printfs Inline

checkbox is selected by default.

Distinct Code Segment for Each Module.

For most applications, the code segment for

each module compiled by the ZNEO compiler is named CODE. Later, in the linker step of
the build process, the linker gathers all these small CODE segments into a single large
CODE segment and then places that segment in the appropriate address space, thus ensur-
ing that all of the executable code is kept in a single contiguous block within a single
address space. However, some users might need a more complex configuration in which
particular code modules are put in different address spaces.

Such users can select the

Distinct Code Segment for Each Module

checkbox to accom-

plish this purpose. When this checkbox is selected, the code segment for every module
receives a distinct name; for example, the code segment generated for the

myModule.c

module is given the name

myModule_TEXT

. You can then add linker directives to the

linker command file to place selected modules in the appropriate address spaces. This
checkbox is deselected by default.

An example of the use of this feature is to place most of the application’s code in the usual
EROM address space (see the

Project Settings—Address Spaces Page

section on page 68

This manual is related to the following products: