3-46
SC100 C Compiler
Using the SC100 C Compiler
3.4.4 Intrinsic Functions
The compiler supports a large number of intrinsic (built-in) functions that map directly to SC100 assembly
instructions. As C does not support fractional types and operations, these intrinsic functions enable
fractional operations to be implemented using integer data types.
The syntax of the compiler group of intrinsic functions is structured for full compatibility with the ETSI
and ITU reference implementations of bit-exact standards.
3.4.4.1 Data types for intrinsic functions
The following four data types are defined for specific use with intrinsic functions:
Fractional short, a 16-bit fractional value mapped to a short, as described in
Section 3.4.2.4,
“
Fractional representation.
”
Fractional long, a 32-bit fractional value mapped to a long, as described in
Section 3.4.2.4,
“
Fractional representation.
”
Extended precision fractional, a 40-bit value which can only be used in intrinsic functions.
See
Section 3.4.4.1.1,
“
Extended precision fractional,
”
for details.
Double precision fractional, a 64-bit value which can only be used in intrinsic functions.
See
Section 3.4.4.1.2,
“
Double precision fractional,
”
for details.
Extended and double precision fractional types enable algorithms to be defined which require precision
larger than 32 bits. These data types can be used only with intrinsic functions and with assignments.
Variables defined as extended and double precision fractionals cannot be used for standard arithmetical or
other operations.
3.4.4.1.1 Extended precision fractional
The extended precision fractional (
Word40
) is a 40-bit data type which occupies the entire Dn (40-bit)
register, as shown in Figure 3-13:
This data type is mapped in the compiler as a structure containing two elements:
A 32-bit integer placed to the right of the binary point.
An 8-bit integer placed to the left of the binary point. These
“
guard bits
”
can be used to ensure a more
accurate result when an overflow occurs.
When stored in memory, an extended precision fractional variable occupies 64 bits. The least significant
32 bits are stored in the first 32-bit word, and the 8 most significant guard bits are stored in the second
32-bit word in an undefined position.
See Table 3-6 on page 3-48 for a list of intrinsic functions for fractional arithmetic using guard bits.
See Example 3-28 on page 3-53 for an illustration of the use of intrinsic functions with extended precision
fractional variables.
Bytes
0
1
2
3
4
extended precision
fractional
guard
bits
high
low
Figure 3-13. Extended Precision Fractional
—
Dn Register Layout