28.2.72 __builtin_max

Architecture

dsPIC33C/E/F, dsPIC30

Description

Force (Signed) Data Range Maximum Limit. Compares a 16-bit signed data value to a maximum signed limit value, both stored in the accumulators.

If the data value is greater than the maximum, the data value is set to the maximum value.

If the data value is less than or equal to the maximum value, the data value is not changed.

Prototype

int16_t __builtin_max(int16_t value, int16_t high);

Arguments

value – Data value

high – Maximum limit value

Return Value

Returns value limited by high.

Machine Instruction

max

Error Messages

None

Example

Assume Accumulator Register A contains 5

Assume Accumulator Register B contains 7

volatile register int accumA asm("A");
volatile register int accumB asm("B");
accumA = __builtin_max(accumA, accumB);

In assembly:

max A

For this example, the value in A will be 5, since A is less than the max value in B.