MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
16-Bit C <strong>Compiler</strong> User’s Guide<br />
__builtin_mac<br />
Description: Computes a x b <strong>and</strong> sums with accumulator; also prefetchs data ready<br />
<strong>for</strong> a future MAC operation.<br />
xptr may be null to signify no X prefetch to be per<strong>for</strong>med, in which<br />
case the values of xincr <strong>and</strong> xval are ignored, but required.<br />
yptr may be null to signify no Y prefetch to be per<strong>for</strong>med, in which<br />
case the values of yincr <strong>and</strong> yval are ignored, but required.<br />
xval <strong>and</strong> yval nominate the address of a C variable where the<br />
prefetched value will be stored.<br />
xincr <strong>and</strong> yincr may be the literal values: -6, -4, -2, 0, 2, 4, 6 or an<br />
integer value.<br />
If AWB is non null, the other accumulator will be written back into the<br />
referenced variable.<br />
For example:<br />
register int result asm("A");<br />
int *xmemory;<br />
int *ymemory;<br />
int xVal, yVal;<br />
result = __builtin_mac(xVal, yVal,<br />
&xmemory, &xVal, 2,<br />
&ymemory, &yVal, 2, 0);<br />
Prototype:<br />
might generate:<br />
mac w4*w5, A, [w8]+=2, w4, [w10]+=2, w5<br />
int __builtin_mac(int a, int b,<br />
int **xptr, int *xval, int xincr,<br />
int **yptr, int *yval, int yincr, int *AWB);<br />
Argument: a Integer multiplic<strong>and</strong>.<br />
b Integer multiplier.<br />
xptr Integer pointer to pointer to x prefetch.<br />
xval Integer pointer to value of x prefetch.<br />
xincr Integer increment value of x prefetch.<br />
yptr Integer pointer to pointer to y prefetch.<br />
yval Integer pointer to value of y prefetch.<br />
yincr Integer increment value of y prefetch.<br />
AWB Integer pointer to accumulator selection.<br />
Return Value: Returns the cleared value result to an accumulator.<br />
Assembler Operator<br />
/ Machine<br />
Instruction:<br />
mac<br />
Error Messages An error message will be displayed if:<br />
• the result is not an accumulator register<br />
• xval is a null value but xptr is not null<br />
• yval is a null value but yptr is not null<br />
__builtin_modsd<br />
Description: Issues the 16-bit architecture’s native signed divide support with the<br />
same restrictions given in the “<strong>dsPIC</strong>30F/33F Programmer’s Reference<br />
Manual” (DS70157). Notably, if the quotient does not fit into a<br />
16-bit result, the results (including remainder) are unexpected. This<br />
<strong>for</strong>m of the builtin function will capture only the remainder.<br />
Prototype: signed int __builtin_modsd(signed long dividend,<br />
signed int divisor);<br />
DS51284G-page 150 © 2008 <strong>Microchip</strong> Technology Inc.