28.2.75 __builtin_maxv_excess

Architecture

dsPIC33C/E/F, dsPIC30

Description

Force (Signed) Data Range Maximum Limit with Limit Excess Result. Compares a 16-bit signed data value to a maximum signed limit value and stores excess result.

Prototype

int16_t __builtin_maxv_excess(int16_t value, int16_t high, int16_t *excess);

Arguments

value – Data value

high – Maximum limit value

excess – Value of excess over limit

Return Value

Returns value limited by high.

Updates excess variable to value of excess over max limit value, else set to 0.

Machine Instruction

max.v

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 excess;
accumA = __builtin_maxv_excess(accumA, accumB, &excess);

In assembly:

max.v A,[excess]

For this example, the value in A will be 5, since A is greater than the max value in B. The excess will be set to 2, which is the excess value.