Always thought float subtraction operation is very simple, is to convert it to __float32_add and __float32_sub These two function calls, and then use software simulation to add and subtract operations. But is it really that simple? Is it still the case when some uncomfortable conditions come into being?
Processing of 1.1 VDSP on float addition and subtraction operation
Under VDSP, you can easily use:
float add(float x, float y)
{
float r = x + y;
return r;
}
float sub(float x, float y)
{
float r = x - y;
return r;
}
To complete the floating-point addition and subtraction operation, the compiler automatically converts the addition operation inside into a ___float32_add function call, and converts the subtraction operation to a ___float32_sub function call, which is implemented in LIBDSP/FPADD.ASM:
___float32_sub:
BITTGl (R1,31); // Flip sign bit of Y, fall through to add
.align 2;
___float32_add:
From these lines of code you can see that subtraction is simply the addition of the meiosis symbol.
1.2 When Y is 0 o'clock
Look at the __float32_add code:
// check for addition of 0.0
R3 = R1 << 1; // Remove sign
CC = R3; // If Y=0, return X
IF !CC JUMP .return_x_nopop;
………..
.return_x_nopop:
#if CHECKING_FOR_NEGZERO_RES
R1 = R0 << 1;
CC = R1;
IF !CC R0 = R1; // convert any -0.0 to 0.0
#endif
RTS;
Returns the value of x directly, at which point the number of cycle required is 25.
1.3 When x is 0 o'clock
R2 = R0 << 1; // Remove sign
CC = R2; // If X=0, return Y
IF !CC JUMP .return_y_nopop;
……….
.return_y_nopop:
R0 = R1;
RTS;
Returns the value of Y directly, at which point the number of cycle required is 26.