📄 basic_op.c
字号:
if ((L_var1<0) && (L_var2 <0) && (L_test >0))
{
Overflow = 1;
carry_int = 1;
}
else
{
if (((L_var1 ^ L_var2) < 0) && (L_test > 0))
{
Overflow = 0;
carry_int = 1;
}
else
{
Overflow = 0;
carry_int = 0;
}
}
}
if (Carry)
{
if (L_test == MAX_32)
{
Overflow = 1;
Carry = carry_int;
}
else
{
if (L_test == (Word32) 0xFFFFFFFFL)
{
Carry = 1;
}
else
{
Carry = carry_int;
}
}
}
else
{
Carry = carry_int;
}
return(L_var_out);
}
/*___________________________________________________________________________
| |
| Function Name : L_macNs |
| |
| Purpose : |
| |
| Multiply var1 by var2 and shift the result left by 1. Add the 32 bit |
| result to L_var3 without saturation, return a 32 bit result. Generate |
| carry and overflow values : |
| L_macNs(L_var3,var1,var2) = L_add_c(L_var3,(L_mult(var1,var2)). |
| |
| Complexity weight : 1 |
| |
| Inputs : |
| |
| L_var3 32 bit long signed integer (Word32) whose value falls in the |
| range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
| |
| var1 |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
| |
| var2 |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
| |
| Outputs : |
| |
| none |
| |
| Return Value : |
| |
| L_var_out |
| 32 bit long signed integer (Word32) whose value falls in the |
| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
| |
| Caution : |
| |
| In some cases the Carry flag has to be cleared or set before using op- |
| rators which take into account its value. |
|___________________________________________________________________________|
*/
inline Word32 L_macNs(Word32 L_var3, Word16 var1, Word16 var2)
{
Word32 L_var_out;
L_var_out = L_mult(var1,var2);
L_var_out = L_add_c(L_var3,L_var_out);
return(L_var_out);
}
/*___________________________________________________________________________
| |
| Function Name : L_msuNs |
| |
| Purpose : |
| |
| Multiply var1 by var2 and shift the result left by 1. Subtract the 32 |
| bit result from L_var3 without saturation, return a 32 bit result. Ge- |
| nerate carry and overflow values : |
| L_msuNs(L_var3,var1,var2) = L_sub_c(L_var3,(L_mult(var1,var2)). |
| |
| Complexity weight : 1 |
| |
| Inputs : |
| |
| L_var3 32 bit long signed integer (Word32) whose value falls in the |
| range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
| |
| var1 |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
| |
| var2 |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
| |
| Outputs : |
| |
| none |
| |
| Return Value : |
| |
| L_var_out |
| 32 bit long signed integer (Word32) whose value falls in the |
| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
| |
| Caution : |
| |
| In some cases the Carry flag has to be cleared or set before using op- |
| rators which take into account its value. |
|___________________________________________________________________________|
*/
inline Word32 L_msuNs(Word32 L_var3, Word16 var1, Word16 var2)
{
Word32 L_var_out;
L_var_out = L_mult(var1,var2);
L_var_out = L_sub_c(L_var3,L_var_out);
return(L_var_out);
}
/*___________________________________________________________________________
| |
| Function Name : L_negate |
| |
| Purpose : |
| |
| Negate the 32 bit variable L_var1 with saturation; saturate in the case |
| where input is -2147483648 (0x8000 0000). |
| |
| Complexity weight : 2 |
| |
| Inputs : |
| |
| L_var1 32 bit long signed integer (Word32) whose value falls in the |
| range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
| |
| Outputs : |
| |
| none |
| |
| Return Value : |
| |
| L_var_out |
| 32 bit long signed integer (Word32) whose value falls in the |
| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
|___________________________________________________________________________|
*/
/*inline Word32 L_negate(Word32 L_var1)
{
Word32 L_var_out;
L_var_out = (L_var1 == MIN_32) ? MAX_32 : -L_var1;
return(L_var_out);
}*/
/*___________________________________________________________________________
| |
| Function Name : mult_r |
| |
| Purpose : |
| |
| Same as mult with rounding, i.e.: |
| mult_r(var1,var2) = shr(((var1*var2) + 16384),15) and |
| mult_r(-32768,-32768) = 32767. |
| |
| Complexity weight : 2 |
| |
| Inputs : |
| |
| var1 |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
| |
| var2 |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
| |
| Outputs : |
| |
| none |
| |
| Return Value : |
| |
| var_out |
| 16 bit short signed integer (Word16) whose value falls in the |
| range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
|___________________________________________________________________________|
*/
/*inline Word16 mult_r(Word16 var1, Word16 var2)
{
Word16 var_out;
Word32 L_produit_arr;
L_produit_arr = (Word32)var1 * (Word32)var2; // product
L_produit_arr += (Word32) 0x00004000; // round
L_produit_arr &= (Word32) 0xffff8000L;
L_produit_arr >>= 15; // shift
if (L_produit_arr & (Word32) 0x00010000L) // sign extend when necessary
{
L_produit_arr |= (Word32) 0xffff0000L;
}
var_out = sature(L_produi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -