Language Features
SC100 C Compiler
3-41
3.4.2.4 Fractional representation
Since C does not provide built-in support for fractional types, the syntactic representation of fractional
types and operations is implemented by intrinsic functions using integer data types. See
Section 3.4.4,
“
Intrinsic Functions,
”
for details of the intrinsic functions supported.
Fixed -point arithmetic is performed using 16-bit, 32-bit, 40-bit, and 64-bit operations. Fractional integers
are stored in memory using little-endian representation, meaning the least significant bits in the lower
address, unless the option
-be
is specified.
Fractional type overflows may saturate and do not result in any additional side effect. Rounding and
saturation modes are determined as part of the startup code, or with optional intrinsic function calls.
Operations on double and extended precision type objects are limited to assignments and fractional
arithmetic using intrinsic functions only. See
Section 3.4.3,
“
Fractional and Integer Arithmetic,
”
for further
information. Integer operations on extended precision types are not supported.
Fractional types are mapped to their corresponding predefined types. A fractional
short
maps to the
predefined type
short
, a fractional
long
maps to the predefined type
long
, and a fractional
int
maps to
the predefined type
int
.
Figure 3-12 illustrates the layout for fractional short and long integers in the Dn (40-bit) data register,
which is the only register used for fractional integer types.
“
S
”
indicates the signed extension of the value.
When loading data from memory into data registers, the compiler aligns the data in the registers according
to the context in which the data is used.
3.4.2.5 Pointers
Pointers contain addresses of data objects or functions. Pointers are represented in memory using 32 bits
(4 bytes). In the small memory model, although pointers are represented in memory using 32 bits, only 16
bits are meaningful. The representation of pointers in memory and in the registers is exactly the same as for
unsigned long integers, as shown in
Section 3.4.2.2,
“
Integers.
”
3.4.2.6 Bit-fields
Members of structures are always allocated on byte boundaries, and are aligned according to their
fundamental base type. However, bit-fields in structures can be allocated at any bit and of any length not
exceeding the size of a long word (32 bits). Signed and unsigned bit-fields are permitted and are sign
extended when fetched. A bit-field of type
int
is considered
signed
.
Bytes
*
S
*
*
*
*
short fractional
(signed)
short fractional
0
Bytes
*
S
*
*
*
*
long / int
fractional
(signed)
long / int fractional
Figure 3-12. Fractional Integers
—
Dn Register Layout