7-20
SC100 C Compiler
Runtime Libraries
7.14 Built-in Intrinsic Functions (prototype.h)
The compiler supports a set of built-in intrinsic functions that enable fractional operations to be
implemented using integer data types, by mapping directly to SC100 assembly instructions.
Table 7-35 lists these built-in intrinsic functions.
Table 7-35. Built-in Intrinsic Functions
Function
Purpose
short abs_s(short var1)
Short absolute value of
var1
. For example, the result of
abs_s(-32768)
is
+32767
.
short add(short var1,short var2)
Short add. Performs the addition
var1+var2
with overflow
control and saturation. The 16-bit result is set at
+32767
when overflow occurs, or at
-32768
when underflow
occurs.
BitReverseUpdate
Increments the iterator with bit reverse.
Word64 D_add(Word64 D_var1,
Word64 D_var2)
Double precision add. Performs the addition
D_var1+D_var2
with overflow control and saturation.
short D_cmpeq(Word64 D_var1,
Word64 D_var2)
Double precision compare equal. Compares two 64-bit
values and returns a 16-bit result containing the value
if the values are equal, or
if they are not.
short D_cmpgt(Word64 D_var1,
Word64 D_var2)
Double precision compare greater than. Compares two
64-bit values and returns a 16-bit result containing
.
long D_extract_h(Word64 D_var1)
Double precision extract high. Returns the 32 MSB of the
64-bit value
D_var1
.
unsigned long D_extract_l
(Word64 D_var1)
Double precision extract low. Returns the 32 LSB of the
64-bit value
D_var1
as an unsigned 32-bit value.
Word64 D_mac(Word64 D_var3,
long L_var1,long L_var2)
Double precision multiply accumulate. Multiplies
L_var1
by
L_var2
and shifts the result left by 1. Adds the 64-bit
result to
L_var3
with saturation, and returns a 64-bit result.
For example:
D_mac(D_var3,L_var1,L_var2) =
D_add(D_var3,D_mult(L_var1,L_var2))
.
Word64 D_msu(Word64 D_var3,
long L_var1,long L_var2)
Double precision multiply subtract. Multiplies
L_var1
by
L_var2
and shifts the result left by 1. Subtracts the 64-bit
result from
D_var3
with saturation, and returns a 64-bit
result. For example:
D_msu(D_var3,L_var1,L_var2) =
D_sub(D_var3,D_mult(L_var1,L_var2))
.
Word64 D_mult(long L_var1,long L_var2)
Double precision multiply. The 64-bit result of the
multiplication of
L_var1
by
L_var2
with one shift left, for
example:
D_mult(L_var1,L_var2) =
D_shl((L_var1*L_var2),1)
.
long D_round(Word64 D_var1)
Double precision round. Rounds the lower 32 bits of the
64-bit
D_var1
into the MS 32 bits with saturation. Shifts the
resulting bits right by 32 and returns the 32-bit value.
Word64 D_sat(Word64 D_var1)
Double precision saturation. Saturates a 64-bit value.