Built-in Intrinsic Functions (prototype.h)
SC100 C Compiler
7-23
long mpyus(long L_var1,long L_var2)
Multiplies the 16 LSB of the 32-bit variable
L_var1
,
treated as an unsigned value, by the 16 MSB of the 32-bit
variable
L_var2
, treated as a signed value. Returns a
32-bit result.
long mpysu(long L_var1,long L_var2)
Multiplies the 16 MSB of the 32-bit variable
L_var1
,
treated as a signed value, by the 16 LSB of the 32-bit
variable
L_var2
, treated as an unsigned value. Returns a
32-bit result.
short msu_r(long L_var3,short var1,
short var2)
Multiply subtract and round. Multiplies
var1
by
var2
and
shifts the result left by 1. Subtracts the 32-bit result from
L_var3
with saturation. Rounds the LS 16 bits of the result
into the MS 16 bits with saturation and shifts the result right
by 16. Returns a 16-bit result.
short mult(short var1,short var2)
Short multiply. Performs the multiplication of
var1
by
var2
and gives a 16-bit result which is scaled, for example:
mult(var1,var2) =
extract_l(L_shr((var1 * var2),15))
and
mult(-32768,-32768) = 32767.
short mult_r(short var1,short var2)
Multiply and round. Same as
mult
with rounding
,
for
example:
mult_r(var1,var2) = extract_l
(L_shr(((var1*var2)+16384),15))
and
mult_r(-32768,-32768) = 32767
.
short negate(short var1)
Short negate. Negates
var1
with saturation. Saturates in
cases where the value is
-32768
, for example:
negate(var1) = sub(0,var1).
short norm_l(long L_var1)
Normalizes any long fractional value.
Produces the number
of left shifts needed to normalize the 32-bit variable
L_var1
for positive values on the interval with minimum of
1073741824
and maximum of
2147483647
, and for
negative values on the interval with minimum of
-2147483648
and maximum of
-1073741824
. In order to
normalize the result, the following operation must be
executed:
norm_L_var1 = L_shl(L_var1,norm_l(L_var1)).
short norm_s(short var1)
Normalizes any fractional value. Produces the number of
left shifts needed to normalize the 16-bit variable
var1
for
positive values on the interval with minimum of
16384
and
maximum of
32767
, and for negative values on the interval
with minimum of
-32768
and maximum of
-16384
. In
order to normalize the result, the following operation must
be executed:
norm_var1 = shl(var1,norm_s(var1)).
short round(long var1)
Round. Rounds the lower 16 bits of the 32-bit number into
the MS 16 bits with saturation. Shifts the resulting bits right
by 16 and returns the 16-bit number, for example:
round(L_var1) =
extract_h(L_add(L_var1,32768)).
short saturate(short var1)
Saturates a 16-bit value.
setcnvrm()
Sets rounding mode to convergent rounding mode.
Table 7-35. Built-in Intrinsic Functions (Continued)
Function
Purpose