Double treated as float, Const keyword and rom – Zilog Z8F0130 User Manual
Page 281

UM013037-1212
Deviations from ANSI C
Zilog Developer Studio II – Z8 Encore!
User Manual
257
Double Treated as Float
The Z8 Encore! C-Compiler does not support a double-precision floating-point type. The
type
double
is accepted but is treated as if it were
float
.
const Keyword and ROM
The Z8 Encore! C-Compiler by default assumes
const
in RAM and places
const
vari-
ables without any storage qualifications in RData for the small model and EData for the
large model. With the
const
in RAM option in affect, the C-Compiler follows the ANSI
C standard rules for
const
parameters.
However, the C-Compiler also provides a deprecated option to place such
const
variables
in ROM memory instead. When this option is selected, the treatment of the
const
key-
word is emphatically non-ANSI. Specifically, when this option is selected, the
const
key-
word is treated as equivalent to
rom
. Then, the function prototype
void foo (const char* src);
implies that the
src
string is in ROM memory, and any code that calls
foo
should pass
only a
const
or
rom
string as
src
string argument. This restriction comes because the Z8
Encore! microcontroller has different machine instructions for accessing its different
memory spaces (LDC, LD, and LDX). This is a deviation from ANSI C. The compiler
reports an “Incompatible data types” error for code that does not follow the preceding
restriction.
Under the ANSI standard, the
const
qualification on a parameter merely implies that the
function cannot modify the parameter and a non-
const
qualified argument can be passed
as the corresponding parameter.
The effect of this deviation from the standard is primarily that, in code that must be porta-
ble for all options of the compiler and linker (such as the source code for library functions
provided by the compiler), parameters cannot be declared
const
.
On new applications, Zilog discourages this use of the
const
keyword to place data in
ROM. Zilog recommends declaring constant data (such as tables) using the
rom
keyword
instead. Where portability is a consideration, this can easily be done by preprocessor mac-
ros.
For example:
#ifdef __EZ8__
# define ROM rom
#else
# define ROM const
#endif
ROM struct TableElement[] table = { /* stuff */};
- 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