Zilog Z8F0130 User Manual
Page 112

Using the Integrated Development Environment
UM013037-1212
88
Zilog Developer Studio II – Z8 Encore!
User Manual
also be seen at the machine instruction level, where a separate instruction,
LDC
, must be
generated by the compiler to load data from the ROM space. That means that if constants
are placed in ROM, a different function must be called if a
const
pointer is used as a
function parameter than the function that is called for a non-
const
pointer type.
For example, consider the following code:
char const *quote = “Ask not ...”;
char buffer[80];
rom_src_strcpy(buffer,quote); // OK if CONST = ROM;
// parameter type mismatch
// if not
strcpy(buffer,quote); // Parameter type mismatch
// if const = ROM, OK otherwise.
The top form shown here calls a function whose signature is
char * rom_src_strcpy (void * dest, rom void * source)
whereas the standard function
strcpy
has the more usual signature
char * strcpy (void * dest, const void * source)
The top form succeeds in this code snippet when the
const=ROM
option has been selected,
and fails otherwise (when
const
data is stored in RAM). The bottom form fails when
const=ROM
but succeeds otherwise. There can never be a case when both calls succeed,
because the second pointer argument of
rom_src_strcpy()
is a fundamentally different
type, pointing into a different space, than the second pointer argument of
strcpy()
.
In short, the result of these architectural constraints is that if the
Place Const Variables in
ROM
checkbox is selected, it is impossible for the compiler to treat the
const
keyword in
a way that complies with the ANSI C Standard.
It is better to not select this deprecated option and let the compiler use
const
variables in
RAM when needed and to use the
rom
keyword explicitly to declare any data such as
tables that you really do want to locate in ROM.
Disable ANSI Promotions
The option of enabling or disabling ANSI promotions refers to promoting
char
and
short
values to
int
s when doing computations, as described in more detail in this sec-
tion. Disabling the promotions was made a user option in earlier releases of ZDS II with
the goal of reducing code size because the promotions called for by the ANSI C standard
are often unnecessary and can lead to considerable code bloat. However, over time, sev-
eral problems were found in the compiler’s ability to apply this option consistently and
correctly in all cases. Therefore, Zilog no longer recommends the use of this feature and,
to address the original code size issue, has expended more effort to reduce code size and
remove truly unnecessary promotions while observing the ANSI standard. For this reason,
the
Disable ANSI Promotions
checkbox is now available only as a deprecated feature. It
remains available because some users have carefully created working code that might
- Z8F0131 Z8F0230 Z8F0231 Z8F0430 Z8F0431 Z8F043A Z8F0830 Z8F0831 Z8F083A Z8F1232 Z8F1233 Z8F0113 Z8F011A Z8F0123 Z8F012A Z8F0213 Z8F021A Z8F0223 Z8F022A Z8F0411 Z8F0412 Z8F0413 Z8F041A Z8F0421 Z8F0422 Z8F0423 Z8F042A Z8F0811 Z8F0812 Z8F0813 Z8F081A Z8F0821 Z8F0822 Z8F0823 Z8F082A Z8F0880 Z8F1621 Z8F1622 Z8F1680 Z8F1681 Z8F1682 Z8F2421 Z8F2422 Z8F2480 Z8F3221 Z8F3222 Z8F3281 Z8F3282 Z8F4821 Z8F4822 Z8F4823 Z8F6081 Z8F6082 Z8F6421 Z8F6422 Z8F6423 Z8F6481 Z8F6482 Z8FS021A ZMOT1AHH Z8FS040B ZMOT0BHH ZMOT0BSB Z8FMC04 Z8FMC08 Z8FMC16