Zilog Z8F0130 Bedienungsanleitung Seite 112

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 214
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 111
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 ints 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 compilers 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
Seitenansicht 111
1 2 ... 107 108 109 110 111 112 113 114 115 116 117 ... 213 214

Kommentare zu diesen Handbüchern

Keine Kommentare