5.2 Built-In Functions List
This section describes the programmer interface to the compiler built-in functions. Since the functions are “built-in”, there are no header files associated with them. Similarly, there are no command-line switches associated with the built-in functions; they are always available. The built-in function names are chosen such that they belong to the compiler’s namespace (they all have the prefix: _builtin_
), so they will not conflict with function or variable names in the programmer’s namespace.
_builtin_addab | |
---|---|
Description: Adds Accumulators A and B with the result written back to the specified accumulator. For example:
will generate:
| |
Prototype:
| |
Argument: Accum_a First accumulator to add. Accum_b Second accumulator to add. | |
Return Value: Returns the addition result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if the result is not an Accumulator register. |
_builtin_add | |
---|---|
Description:
If
| |
Prototype:
| |
Argument: Accum Accumulator to add. value Integer number to add to accumulator value. shift Amount to shift resultant accumulator value. | |
Return Value: Returns the shifted addition result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_btg | |
---|---|
Description: This function will generate a
Note that taking the address of a variable in a register will produce a warning by the compiler and cause the register to be saved onto the stack (so that its address may be taken); this form is not recommended. This caution only applies to variables explicitly placed in registers by the programmer. | |
Prototype:
| |
Argument: * A pointer to the data item for which a bit should be toggled. 0xn A literal value in the range of 0 to 15. | |
Return Value: Returns a | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if the parameter values are not within range. |
_builtin_clr | |
---|---|
Description: Clears the specified accumulator. For example:
will generate:
| |
Prototype:
| |
Argument: None. | |
Return Value: Returns the cleared value result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if the result is not an Accumulator register. |
_builtin_divf | |
---|---|
Description: Computes the quotient: num / den. A math error exception occurs if den is zero. Function arguments are unsigned, as is the function result. | |
Prototype:
| |
Argument: num Numerator. den Denominator. | |
Return Value: Returns the unsigned integer value of the quotient: num / den. | |
Assembler Operator/Machine Instruction:
|
_builtin_divmodsd | |
---|---|
Description: Issues the 16-bit architecture’s native signed divide support. Notably, if the quotient does not fit into a 16-bit result, the results (including remainder) are unexpected. This form of the built-in function will capture both the quotient and remainder. | |
Prototype:
| |
Argument: dividend Number to be divided. divisor Number to divide by. remainder Pointer to remainder. | |
Return Value: Quotient and remainder. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: None. |
_builtin_divmodud | |
---|---|
Description: Issues the 16-bit architecture’s native unsigned divide support. Notably, if the quotient does not fit into a 16-bit result, the results (including remainder) are unexpected. This form of the built-in function will capture both the quotient and remainder. | |
Prototype:
| |
Argument: dividend Number to be divided. divisor Number to divide by. remainder Pointer to remainder. | |
Return Value: Quotient and remainder. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: None. |
_builtin_divsd | |
---|---|
Description: Computes the quotient: num / den. A math error exception occurs if den is zero. Function arguments are signed, as is the function result. The command-line option, | |
Prototype:
| |
Argument: num Numerator. den Denominator. | |
Return Value: Returns the signed integer value of the quotient: num / den. | |
Assembler Operator/Machine Instruction:
|
_builtin_divud | |
---|---|
Description: Computes the quotient: num / den. A math error exception occurs if den is zero. Function arguments are unsigned, as is the function result. The command-line option, | |
Prototype:
| |
Argument: num Numerator. den Denominator. | |
Return Value: Returns the unsigned integer value of the quotient: num / den. | |
Assembler Operator/Machine Instruction:
|
_builtin_dmaoffset | |
---|---|
Description: Obtains the offset of a symbol within DMA memory. For example:
May generate:
| |
Prototype:
| |
Argument: *p Pointer to DMA address value. | |
Return Value: Returns the offset to a variable located in DMA memory. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if the parameter is not the address of a global symbol. |
_builtin_ed | |
---|---|
Description: Squares
For example:
May generate:
| |
Prototype:
| |
Argument: sqr Integer squared value. xptr Integer Pointer to pointer to X prefetch. xincr Integer increment value of X prefetch. yptr Integer Pointer to pointer to Y prefetch. yincr Integer increment value of Y prefetch. distance Integer Pointer to distance. | |
The arguments, xptr and yptr, must point to the arrays located in the X data memory and Y data memory, respectively. | |
Return Value: Returns the squared result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_edac | |
---|---|
Description: Squares
For example:
May generate:
| |
Prototype:
| |
Argument: Accum Accumulator to sum. sqr Integer squared value. xptr Integer Pointer to pointer to X prefetch. xincr Integer increment value of X prefetch. yptr Integer Pointer to pointer to Y prefetch. yincr Integer increment value of Y prefetch. distance Integer Pointer to distance. | |
The arguments, xptr and yptr, must point to the arrays located in the X data memory and Y data memory, respectively. | |
Return Value: Returns the squared result to specified accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_fbcl | |
---|---|
Description: Finds the first bit change from left in value. This is useful for dynamic scaling of fixed-point data. For example:
May generate:
| |
Prototype:
| |
Argument: value Integer number of first bit change. | |
Return Value: Returns the shifted addition result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if the result is not an Accumulator register. |
_builtin_lac | |
---|---|
Description: Shifts value by shift (a literal between -8 and 7) and returns the value to be stored into the Accumulator register. For example:
May generate:
| |
Prototype:
| |
Argument: value Integer number to be shifted. shift Literal amount to shift. | |
Return Value: Returns the shifted addition result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_mac | |
---|---|
Description: Computes a x b and sums with the accumulator; it also prefetches data ready for a future xptr may be null to signify no X prefetch to be performed; in which case, the values of xincr and xval are ignored but required. yptr may be null to signify no Y prefetch to be performed; in which case, the values of yincr and yval are ignored but required. xval and yval nominate the address of a C variable where the prefetched value will be stored. xincr and yincr may be the literal values: -6, -4, -2, 0, 2, 4, 6 or an integer value. If AWB is non-null, the other accumulator will be written back into the referenced variable. For example:
May generate:
| |
Prototype:
| |
Argument: Accum Accumulator to sum. a Integer multiplicand. b Integer multiplier. xptr Integer Pointer to pointer to X prefetch. xval Integer Pointer to value of X prefetch. xincr Integer increment value of X prefetch. yptr Integer Pointer to pointer to Y prefetch. yval Integer Pointer to value of Y prefetch. yincr Integer increment value of Y prefetch. AWB Accumulator Write-Back location. AWB_accum Accumulator to Write-Back. | |
The arguments, xptr and yptr, must point to the arrays located in the X data memory and Y data memory, respectively. | |
Return Value: Returns the cleared value result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_modsd | |
---|---|
Description: Issues the 16-bit architecture’s native signed divide support. Notably, if the quotient does not fit into a 16-bit result, the results (including remainder) are unexpected. This form of the built-in function will capture only the remainder. | |
Prototype:
| |
Argument: dividend Number to be divided. divisor Number to divide by. | |
Return Value: Remainder. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: None. |
_builtin_modud | |
---|---|
Description: Issues the 16-bit architecture’s native unsigned divide support. Notably, if the quotient does not fit into a 16-bit result, the results (including remainder) are unexpected. This form of the built-in function will capture only the remainder. | |
Prototype:
| |
Argument: dividend Number to be divided. divisor Number to divide by. | |
Return Value: Remainder. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: None. |
_builtin_mpy | |
---|---|
Description: Computes a x b; also, prefetches data ready for a future xptr may be null to signify no X prefetch to be performed; in which case, the values of xincr and xval are ignored but required. yptr may be null to signify no Y prefetch to be performed; in which case, the values of yincr and yval are ignored but required. xval and yval nominate the address of a C variable where the prefetched value will be stored. xincr and yincr may be the literal values: -6, -4, -2, 0, 2, 4, 6 or an integer value. For example:
May generate:
| |
Prototype:
| |
Argument: a Integer multiplicand. b Integer multiplier. xptr Integer Pointer to pointer to X prefetch. xval Integer Pointer to value of X prefetch. xincr Integer increment value of X prefetch. yptr Integer Pointer to pointer to Y prefetch. yval Integer Pointer to value of Y prefetch. yincr Integer increment value of Y prefetch. AWB Integer Pointer to accumulator selection. | |
The arguments xptr and yptr must point to the arrays located in the X data memory and the Y data memory, respectively. | |
Return Value: Returns the cleared value result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_mpyn | |
---|---|
Description: Computes -a x b; also, prefetches data ready for a future xptr may be null to signify no X prefetch to be performed; in which case, the values of xincr and xval are ignored but required. yptr may be null to signify no Y prefetch to be performed; in which case, the values of yincr and yval are ignored but required. xval and yval nominate the address of a C variable where the prefetched value will be stored. xincr and yincr may be the literal values: -6, -4, -2, 0, 2, 4, 6 or an integer value. For example:
May generate:
| |
Prototype:
| |
Argument: a Integer multiplicand. b Integer multiplier. xptr Integer Pointer to pointer to X prefetch. xval Integer Pointer to value of X prefetch. xincr Integer increment value of X prefetch. yptr Integer Pointer to pointer to Y prefetch. yval Integer Pointer to value of Y prefetch. yincr Integer increment value of Y prefetch. AWB Integer Pointer to accumulator selection. | |
The arguments xptr and yptr must point to the arrays located in the X data memory and the Y data memory, respectively. | |
Return Value: Returns the cleared value result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_msc | |
---|---|
Description: Computes a x b and subtracts from accumulator; also, prefetches data ready for a future xptr may be null to signify no X prefetch to be performed; in which case, the values of xincr and xval are ignored but required. yptr may be null to signify no Y prefetch to be performed; in which case, the values of yincr and yval are ignored but required. xval and yval nominate the address of a C variable where the prefetched value will be stored. xincr and yincr may be the literal values: -6, -4, -2, 0, 2, 4, 6 or an integer value. If AWB is non-null, the other accumulator will be written back into the referenced variable. For example:
May generate:
| |
Prototype:
| |
Argument: Accum Accumulator to sum. a Integer multiplicand. b Integer multiplier. xptr Integer Pointer to pointer to X prefetch. xval Integer Pointer to value of X prefetch. xincr Integer increment value of X prefetch. yptr Integer Pointer to pointer to Y prefetch. yval Integer Pointer to value of Y prefetch. yincr Integer increment value of Y prefetch. AWB Accumulator Write-Back location. AWB_accum Accumulator to Write-Back. | |
The arguments xptr and yptr must point to the arrays located in the X data memory and the Y data memory, respectively. | |
Return Value: Returns the cleared value result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_mulss | |
---|---|
Description: Computes the product p0 x p1. Function arguments are signed integers and the function result is a signed long integer. The command-line option, | |
Prototype:
| |
Argument: p0 Multiplicand. p1 Multiplier. | |
Return Value: Returns the signed long integer value of the product p0 x p1. | |
Assembler Operator/Machine Instruction:
|
_builtin_mulsu | |
---|---|
Description: Computes the product p0 x p1. Function arguments are integers with mixed signs and the function result is a signed long integer. The command-line option, | |
Prototype:
| |
Argument: p0 Multiplicand. p1 Multiplier. | |
Return Value: Returns the signed long integer value of the product p0 x p1. | |
Assembler Operator/Machine Instruction:
|
_builtin_mulus | |
---|---|
Description: Computes the product p0 x p1. Function arguments are integers with mixed signs and the function result is a signed long integer. The command-line option, | |
Prototype:
| |
Argument: p0 Multiplicand. p1 Multiplier. | |
Return Value: Returns the signed long integer value of the product p0 x p1. | |
Assembler Operator/Machine Instruction:
|
_builtin_muluu | |
---|---|
Description: Computes the product p0 x p1. Function arguments are unsigned integers and the function result is an unsigned long integer. The command-line option, | |
Prototype:
| |
Argument: p0 Multiplicand. p1 Multiplier. | |
Return Value: Returns the signed long integer value of the product p0 x p1. | |
Assembler Operator/Machine Instruction:
|
_builtin_nop | |
---|---|
Description: Generates a | |
Prototype:
| |
Argument: None. | |
Return Value: Returns a no operation ( | |
Assembler Operator/Machine Instruction:
|
_builtin_readsfr | |
---|---|
Description: Reads the SFR. | |
Prototype:
| |
Argument: p Object address. | |
Return Value: Returns the SFR. | |
Assembler Operator/Machine Instruction:
|
_builtin_return_address | |
---|---|
Description: Returns the return address of the current function or of one of its callers. For the level argument, a value of zero yields the return address of the current function, a value of one yields the return address of the caller of the current function, and so forth. When level exceeds the current stack depth, zero will be returned. This function should only be used with a non-zero argument for debugging purposes. | |
Prototype:
| |
Argument: level Number of frames to scan up the call stack. | |
Return Value: Returns the return address of the current function or of one of its callers. | |
Assembler Operator/Machine Instruction:
|
_builtin_sac | |
---|---|
Description: Shifts value by shift (a literal between -8 and 7) and returns the value. For example:
May generate:
| |
Prototype:
| |
Argument: value Integer number to be shifted. shift Literal amount to shift. | |
Return Value: Returns the shifted result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_sacr | |
---|---|
Description: Shifts value by shift (a literal between -8 and 7) and returns the value, which is rounded using the Rounding mode determined by the RND (CORCON<1>) control bit. For example:
May generate:
| |
Prototype:
| |
Argument: value Integer number to be shifted. shift Literal amount to shift. | |
Return Value: Returns the shifted result to the CORCON register. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_sftac | |
---|---|
Description: Shifts accumulator by shift. The valid shift range is -16 to 16. For example:
May generate:
| |
Prototype:
| |
Argument: Accum Accumulator to shift. shift Amount to shift. | |
Return Value: Returns the shifted result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if:
|
_builtin_subab | |
---|---|
Description: Subtracts accumulators A and B with the result written back to the specified accumulator. For example:
Will generate:
| |
Prototype:
| |
Argument: Accum_a Accumulator from which to subtract. Accum_b Accumulator to subtract. | |
Return Value: Returns the subtraction result to an accumulator. | |
Assembler Operator/Machine Instruction:
| |
Error Messages: An error message appears if the result is not an Accumulator register. |