User`s guide

Inline Assembly Language and Intrinsics
Intrinsic Functions
142
Targeting MC56F83xx/DSP5685x Controllers
* Allowed dst regs: (same)
*
* Assumptions: OMR's SA bit was set to 1 at least 3 cycles
* before this code.
*/
asm(abs svar1);
return svar1;
}
Fractional Arithmetic
Many of the intrinsic functions use fractional arithmetic with implied fractional
values. An implied fractional value is a symbol declared as an integer type, but
calculated as a fractional type. Data in a memory location or register can be interpreted
as fractional or integer, depending on program needs.
All intrinsic functions that generate multiply or divide instructions perform fractional
arithmetic on implied fractional values. (These intrinsic functions are DIV, MPY,
MAC, MPYR, and MACR) The relationship between a 16-bit integer and a fractional
value is:
Fractional Value = Integer Value / (2
15
)
The relationship between a 32-bit integer and a fractional value is similar:
Fractional Value = Long Integer Value / (2
31
)
Table 7.1
shows how 16- and 32-bit values can be interpreted as either fractional or
integer values.
Table 7.1 Interpretation of 16- and 32-bit Values
Type Hex Integer Value Fixed-point Value
short int 0x2000 8192 0.25
short int 0xE000 -8192 -0.25
long int 0x20000000 536870912 0.25
long int 0xE0000000 -536870912 -0.25