28.2.74 __builtin_max_excess

Architecture

dsPIC33C/E/F, dsPIC30

Description

Force (Signed) Data Range Maximum Limit with Limit Excess Direction. Compares a 16-bit signed data value to a maximum signed limit value and updates flag if excess.

Prototype

int16_t __builtin_max_excess(int16_t value, int16_t high, int16_t *flag_excess);

Arguments

value – Data value

high – Maximum limit value

flag_excess – 1 if data exceeds (is greater than) limit, else 0

Return Value

Returns value limited by high.

Updates flag_excess value to 1 if data value exceeds max limit value, else set to 0.

Machine Instruction

max

Error Messages

None

Example

Assume Accumulator Register A contains 7

Assume Accumulator Register B contains 5

volatile register int accumA asm("A");
volatile register int accumB asm("B");
int16_t flag_excess;
accumA = __builtin_max_excess(accumA, accumB, &flag_excess);

In assembly:

max A,[flag_excess]

For this example, the value in A will be 5, since A is greater than the max value in B. The flag_excess will be set to 1, to indicate that the data value exceeds the max limit value.