Floating-point operations in VDSP (bf561): fract16 addition and subtraction operations

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.