Since subtraction can actually be seen as adding a negative number, we only need to see the addition operation. The addition operation of the fract16 is accomplished by the add_fr1x16 function:
#pragma inline
#pragma always_inline
static fract16 add_fr1x16(fract16 __a, fract16 __b) {
fract16 __rval = __builtin_add_fr1x16(__a, __b);
return __rval;
}
From here we can see that we can actually use __builtin_add_fr1x16 this function call.
Write a very simple program:
typedef fract16 ft;
ft calc(ft x, ft y)
{
ft r;
r = __builtin_add_fr1x16(x, y);
return r;
}
This function expands after the assembly code is:
_calc:
.LN_calc:
//-------------------------------------------------------------------
// Procedure statistics:
// Frame size = 8
// Scratch registers used:{R0.L,R0.H,R1.L,ASTAT0-ASTAT1}
// Call preserved registers used:{FP,SP,RETS}
//-------------------------------------------------------------------
// line ".\float_test.c":27
LINK 0;
W[FP + 12] = R1;
W[FP + 8] = R0;
.LN0:
// line 29
R0.L = R1.L + R0.L (S);
R0 = R0.L (X);
W[FP + 16] = R0;
.LN1:
// line 30
UNLINK;
RTS;
.LN._calc.end:
._calc.end:
.global _calc;
.type _calc,STT_FUNC;