/*
***********************************************************************
*
* Copyright (C) 1999 Ericsson Radio Systems AB
* 
* The Association of Radio Industries and Businesses (ARIB) has the
* licence to reproduce, distribute and publish the Bit Exact C Code
* programs in this CD-ROM together with the other parts of the RCR
* STD-27 (Personal Digital Cellular Telecommunication System)
* specification.
* 
* Ericsson has declared Option 1 (royalty-free licence) to ARIB for
* its Essential Industrial Property Rights related to the ACELP
* specification and the Bit Exact C Code programs. The royalty-free
* licence is limited to the development and manufacturing of
* products complying with the RCR STD-27H specification (or
* subsequent versions) for sale and use in Japan. Copying of the
* program(s) for any other purpose requires the prior written
* permission from Ericsson.
* 
* The user of the Bit Exact C Code hereby acknowledges the
* following:
* 
* 1.  Ericsson does not provide the user with any warranties,
*     whether express or implied, including but not limited to
*     warranties of merchantability and fitness for a particular
*     purpose relating to the Bit Exact C Code.
* 
* 2.  Ericsson shall have no responsibility whatsoever to indemnify
*     the user against actions or claims for infringement of any
*     intellectual property rights, e.g. patents, copyrights,
*     registered designs or any other rights, by reason of the
*     user's use of the Bit Exact C Code.
* 
***********************************************************************
*/

/*___________________________________________________________________________
 |                                                                           |
 |   Constants and Globals                                                   |
 |___________________________________________________________________________|
*/
extern Flag Overflow;
extern Flag Carry;

#define MAX_32 (Word32)0x7fffffffL
#define MIN_32 (Word32)0x80000000L

#define MAX_16 (Word16)0x7fff
#define MIN_16 (Word16)0x8000


/*___________________________________________________________________________
 |                                                                           |
 |   Prototypes for basic arithmetic operators                               |
 |___________________________________________________________________________|
*/

Word16 add(Word16 var1, Word16 var2);
Word16 sub(Word16 var1, Word16 var2);
Word16 abs_s(Word16 var1);
Word16 shl(Word16 var1, Word16 var2);
Word16 shr(Word16 var1, Word16 var2);
Word16 mult(Word16 var1, Word16 var2);
Word32 L_mult(Word16 var1, Word16 var2);
Word16 negate(Word16 var1);
Word16 extract_h(Word32 L_var1);
Word16 extract_l(Word32 L_var1);
Word16 round(Word32 L_var1);
Word32 L_mac(Word32 L_var3, Word16 var1, Word16 var2);
Word32 L_msu(Word32 L_var3, Word16 var1, Word16 var2);
Word32 L_macNs(Word32 L_var3, Word16 var1, Word16 var2);
Word32 L_msuNs(Word32 L_var3, Word16 var1, Word16 var2);

Word32 L_add(Word32 L_var1, Word32 L_var2);
Word32 L_sub(Word32 L_var1, Word32 L_var2);
Word32 L_add_c(Word32 L_var1, Word32 L_var2);
Word32 L_sub_c(Word32 L_var1, Word32 L_var2);
Word32 L_negate(Word32 L_var1);
Word16 mult_r(Word16 var1, Word16 var2);
Word32 L_shl(Word32 L_var1, Word16 var2);
Word32 L_shr(Word32 L_var1, Word16 var2);
Word16 shr_r(Word16 var1, Word16 var2);
Word16 mac_r(Word32 L_var3, Word16 var1, Word16 var2);
Word16 msu_r(Word32 L_var3, Word16 var1, Word16 var2);
Word32 L_deposit_h(Word16 var1);
Word32 L_deposit_l(Word16 var1);

Word32 L_shr_r(Word32 L_var1, Word16 var2);
Word32 L_abs(Word32 L_var1);

Word32 L_sat(Word32 L_var1);

Word16 norm_s(Word16 var1);

Word16 div_s(Word16 var1, Word16 var2);

Word16 norm_l(Word32 L_var1);
