Welcome

首页 / 软件开发 / C++ / Vdsp(bf561)中的浮点运算(12):fract16加减运算

Vdsp(bf561)中的浮点运算(12):fract16加减运算2010-02-01 csdn博客 快乐虾由于减法实际可以看成加上一个负数,因此我们只需要看加法操作。fract16的加法运算由add_fr1x16函数完成:

#pragma inline
#pragma always_inline
static fract16 add_fr1x16(fract16 __a, fract16 __b) {
fract16 __rval = __builtin_add_fr1x16(__a, __b);
return __rval;
}

从这里可以看出我们实际可以使用__builtin_add_fr1x16这一函数调用。

写一个很简单的程序:

typedef fract16 ft;

ft calc(ft x, ft y)
{
ft r;
r = __builtin_add_fr1x16(x, y);
return r;
}

这个函数展开后的汇编代码为:

_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;