[an error occurred while processing this directive]
|
/************************************************************************
**
** L_sub.asm : $Revision: 1.4 $
**
** (c) Copyright 2001-2002 Analog Devices, Inc. All rights reserved.
**
*************************************************************************/
#if 0
basicop2.c comment:
/*___________________________________________________________________________
| |
| Function Name : L_sub |
| |
| Purpose : |
| |
| 32 bits subtraction of the two 32 bits variables (L_var1-L_var2) with |
| overflow control and saturation; the result is set at +2147483647 when |
| overflow occurs or at -2147483648 when underflow occurs. |
| |
| Complexity weight : 2 |
| |
| Inputs : |
| |
| L_var1 32 bit long signed integer (Word32) whose value falls in the |
| range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
| |
| L_var2 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. |
|___________________________________________________________________________|
*/
C source:
Word32 L_sub (Word32 L_var1, Word32 L_var2)
{
Word32 L_var_out;
L_var_out = L_var1 - L_var2;
if (((L_var1 ^ L_var2) & MIN_32) != 0)
{
if ((L_var_out ^ L_var1) & MIN_32)
{
L_var_out = (L_var1 < 0L) ? MIN_32 : MAX_32;
Overflow = 1;
}
}
return (L_var_out);
}
scratch registers used:
AX0 AY0 AX1 AY1 AR SR1 SR0 I0
#endif
#ifdef __NO_ETSI_FLAGS
# define FUNC __etsi_L_sub_noflags
# define FUNC2 __etsi_L_sub_noflags_inregs
#else
.extern _Overflow;
# define FUNC __etsi_L_sub
# define FUNC2 __etsi_L_sub_inregs
#endif
.section/code program;
.global FUNC, FUNC2;
FUNC:
I0 = I4;
MODIFY (I0 += M1);
AX1 = DM(I0 += M1);
AX0 = DM(I0 += M1);
AY1 = DM(I0 += M1);
AY0 = DM(I0 += M2);
FUNC2:
AR = AX0 - AY0; // sub lsw's of input
AR = AX1 - AY1 + C -1, SR0 = AR ; // sub msw's of input
IF NOT AV RTS; // test for overflow or underflow
AR = PASS 1, SR1=AR;
AF = TSTBIT 15 OF AX1;
// can only overflow or underflow if
// inputs are different signs.
// +- inputs == overflow
// -+ inputs == underflow
#ifndef __NO_ETSI_FLAGS
DM(_Overflow)=AR;
#endif
SR1 = 0x7fff;
SR0 = 0xffff;
IF GE RTS; // overflow
SR1 = 0x8000;
SR0 = 0x0000;
RTS; // underflow
.FUNC.end:
.FUNC2.end:
// end of file
E-mail: info@telesys.ru