FreeCalypso > hg > gsm-codec-lib
annotate libtwamr/basicop2.c @ 270:bee3a94f42a7
libgsmfr2: integrate rpe.c from libgsm
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Apr 2024 02:13:17 +0000 |
parents | 57b4053559ff |
children |
rev | line source |
---|---|
252
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 | Basic arithmetic operators. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 | $Id $ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 | Include-Files | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <stdint.h> |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "typedef.h" |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "namespace.h" |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "basic_op.h" |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #include "count.h" |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 extern BASIC_OP multiCounter[MAXCOUNTERS]; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 extern int currCounter; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 | Functions | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 | Function Name : saturate | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 | Limit the 32 bit input to the range of a 16 bit word. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 | L_var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 static inline Word16 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 saturate (Word32 L_var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 if (L_var1 > 0X00007fffL) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 var_out = MAX_16; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 else if (L_var1 < (Word32) 0xffff8000L) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 var_out = MIN_16; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 var_out = extract_l (L_var1); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 multiCounter[currCounter].extract_l--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 | Function Name : add | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 | Performs the addition (var1+var2) with overflow control and saturation;| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 | the 16 bit result is set at +32767 when overflow occurs or at -32768 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 | when underflow occurs. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 Word16 add (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 Word32 L_sum; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 L_sum = (Word32) var1 + var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 var_out = saturate (L_sum); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 multiCounter[currCounter].add++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 | Function Name : sub | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 | Performs the subtraction (var1+var2) with overflow control and satu- | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 | ration; the 16 bit result is set at +32767 when overflow occurs or at | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 | -32768 when underflow occurs. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 Word16 sub (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 Word32 L_diff; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 L_diff = (Word32) var1 - var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 var_out = saturate (L_diff); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 multiCounter[currCounter].sub++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 | Function Name : abs_s | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 | Absolute value of var1; abs_s(-32768) = 32767. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 | range : 0x0000 0000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 Word16 abs_s (Word16 var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 if (var1 == (Word16) 0X8000) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 var_out = MAX_16; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 if (var1 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 var_out = -var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 var_out = var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 multiCounter[currCounter].abs_s++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 | Function Name : shl | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 | Arithmetically shift the 16 bit input var1 left var2 positions.Zero fill| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 | the var2 LSB of the result. If var2 is negative, arithmetically shift | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 | var1 right by -var2 with sign extension. Saturate the result in case of | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 | underflows or overflows. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 Word16 shl (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 Word32 result; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 if (var2 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 if (var2 < -16) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 var2 = -16; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 var_out = shr (var1, -var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 multiCounter[currCounter].shr--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 result = (Word32) var1 *((Word32) 1 << var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 if ((var2 > 15 && var1 != 0) || (result != (Word32) ((Word16) result))) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 var_out = (var1 > 0) ? MAX_16 : MIN_16; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 var_out = extract_l (result); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 multiCounter[currCounter].extract_l--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 multiCounter[currCounter].shl++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 | Function Name : shr | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 | Arithmetically shift the 16 bit input var1 right var2 positions with | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 | sign extension. If var2 is negative, arithmetically shift var1 left by | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 | -var2 with sign extension. Saturate the result in case of underflows or | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 | overflows. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 Word16 shr (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 if (var2 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 if (var2 < -16) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 var2 = -16; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 var_out = shl (var1, -var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 multiCounter[currCounter].shl--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 if (var2 >= 15) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 var_out = (var1 < 0) ? -1 : 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 if (var1 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 var_out = ~((~var1) >> var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 var_out = var1 >> var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 multiCounter[currCounter].shr++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 | Function Name : mult | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 | Performs the multiplication of var1 by var2 and gives a 16 bit result | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 | which is scaled i.e.: | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 | mult(var1,var2) = extract_l(L_shr((var1 times var2),15)) and | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 | mult(-32768,-32768) = 32767. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 Word16 mult (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 Word32 L_product; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 L_product = (Word32) var1 *(Word32) var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 L_product = (L_product & (Word32) 0xffff8000L) >> 15; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 if (L_product & (Word32) 0x00010000L) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 L_product = L_product | (Word32) 0xffff0000L; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 var_out = saturate (L_product); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 multiCounter[currCounter].mult++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 | Function Name : L_mult | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 | L_mult is the 32 bit result of the multiplication of var1 times var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 | with one shift left i.e.: | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 | L_mult(var1,var2) = L_shl((var1 times var2),1) and | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 | L_mult(-32768,-32768) = 2147483647. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 Word32 L_mult (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 L_var_out = (Word32) var1 *(Word32) var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 if (L_var_out != (Word32) 0x40000000L) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 L_var_out *= 2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 L_var_out = MAX_32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 multiCounter[currCounter].L_mult++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 | Function Name : negate | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 | Negate var1 with saturation, saturate in the case where input is -32768:| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 | negate(var1) = sub(0,var1). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 Word16 negate (Word16 var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 var_out = (var1 == MIN_16) ? MAX_16 : -var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 multiCounter[currCounter].negate++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 | Function Name : extract_h | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 | Return the 16 MSB of L_var1. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 | L_var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 | 32 bit long signed integer (Word32 ) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 Word16 extract_h (Word32 L_var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 var_out = (Word16) (L_var1 >> 16); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 multiCounter[currCounter].extract_h++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 | Function Name : extract_l | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 | Return the 16 LSB of L_var1. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 | L_var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 | 32 bit long signed integer (Word32 ) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 Word16 extract_l (Word32 L_var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 var_out = (Word16) L_var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 multiCounter[currCounter].extract_l++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 | Function Name : round | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 | Round the lower 16 bits of the 32 bit input number into the MS 16 bits | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 | with saturation. Shift the resulting bits right by 16 and return the 16 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 | bit number: | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 | round(L_var1) = extract_h(L_add(L_var1,32768)) | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 | L_var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 | 32 bit long signed integer (Word32 ) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 Word16 round (Word32 L_var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 Word32 L_rounded; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 L_rounded = L_add (L_var1, (Word32) 0x00008000L); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 multiCounter[currCounter].L_add--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 var_out = extract_h (L_rounded); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 multiCounter[currCounter].extract_h--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 multiCounter[currCounter].round++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 | Function Name : L_mac | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
657 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
658 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
659 | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
660 | result to L_var3 with saturation, return a 32 bit result: | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
661 | L_mac(L_var3,var1,var2) = L_add(L_var3,L_mult(var1,var2)). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
662 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
663 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
664 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
665 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
666 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
667 | L_var3 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
668 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
669 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
670 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
671 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
672 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
673 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
674 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
675 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
676 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
677 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
678 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
679 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
680 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
681 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
682 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
683 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
684 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
685 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
686 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
687 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
688 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
689 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
690 Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
691 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
692 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
693 Word32 L_product; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
694 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
695 L_product = L_mult (var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
696 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
697 multiCounter[currCounter].L_mult--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
698 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
699 L_var_out = L_add (L_var3, L_product); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
700 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
701 multiCounter[currCounter].L_add--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
702 multiCounter[currCounter].L_mac++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
703 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
704 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
705 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
706 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
707 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
708 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
709 | Function Name : L_msu | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
710 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
711 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
712 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
713 | Multiply var1 by var2 and shift the result left by 1. Subtract the 32 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
714 | bit result to L_var3 with saturation, return a 32 bit result: | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
715 | L_msu(L_var3,var1,var2) = L_sub(L_var3,L_mult(var1,var2)). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
716 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
717 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
718 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
719 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
720 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
721 | L_var3 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
722 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
723 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
724 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
725 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
726 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
727 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
728 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
729 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
730 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
731 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
732 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
733 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
734 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
735 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
736 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
737 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
738 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
739 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
740 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
741 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
742 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
743 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
744 Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
745 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
746 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
747 Word32 L_product; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
748 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
749 L_product = L_mult (var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
750 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
751 multiCounter[currCounter].L_mult--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
752 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
753 L_var_out = L_sub (L_var3, L_product); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
754 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
755 multiCounter[currCounter].L_sub--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
756 multiCounter[currCounter].L_msu++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
757 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
758 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
759 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
760 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
761 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
762 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
763 | Function Name : L_macNs | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
764 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
765 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
766 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
767 | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
768 | result to L_var3 without saturation, return a 32 bit result. Generate | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
769 | carry and overflow values : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
770 | L_macNs(L_var3,var1,var2) = L_add_c(L_var3,L_mult(var1,var2)). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
771 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
772 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
773 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
774 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
775 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
776 | L_var3 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
777 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
778 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
779 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
780 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
781 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
782 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
783 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
784 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
785 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
786 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
787 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
788 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
789 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
790 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
791 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
792 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
793 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
794 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
795 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
796 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
797 | Caution : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
798 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
799 | In some cases the Carry flag has to be cleared or set before using | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
800 | operators which take into account its value. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
801 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
802 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
803 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
804 Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
805 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
806 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
807 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
808 L_var_out = L_mult (var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
809 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
810 multiCounter[currCounter].L_mult--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
811 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
812 L_var_out = L_add_c (L_var3, L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
813 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
814 multiCounter[currCounter].L_add_c--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
815 multiCounter[currCounter].L_macNs++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
816 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
817 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
818 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
819 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
820 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
821 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
822 | Function Name : L_msuNs | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
823 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
824 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
825 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
826 | Multiply var1 by var2 and shift the result left by 1. Subtract the 32 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
827 | bit result from L_var3 without saturation, return a 32 bit result. Ge- | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
828 | nerate carry and overflow values : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
829 | L_msuNs(L_var3,var1,var2) = L_sub_c(L_var3,L_mult(var1,var2)). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
830 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
831 | Complexity weight : 1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
832 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
833 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
834 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
835 | L_var3 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
836 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
837 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
838 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
839 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
840 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
841 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
842 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
843 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
844 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
845 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
846 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
847 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
848 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
849 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
850 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
851 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
852 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
853 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
854 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
855 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
856 | Caution : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
857 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
858 | In some cases the Carry flag has to be cleared or set before using | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
859 | operators which take into account its value. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
860 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
861 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
862 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
863 Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
864 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
865 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
866 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
867 L_var_out = L_mult (var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
868 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
869 multiCounter[currCounter].L_mult--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
870 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
871 L_var_out = L_sub_c (L_var3, L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
872 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
873 multiCounter[currCounter].L_sub_c--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
874 multiCounter[currCounter].L_msuNs++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
875 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
876 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
877 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
878 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
879 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
880 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
881 | Function Name : L_add | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
882 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
883 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
884 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
885 | 32 bits addition of the two 32 bits variables (L_var1+L_var2) with | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
886 | overflow control and saturation; the result is set at +2147483647 when | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
887 | overflow occurs or at -2147483648 when underflow occurs. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
888 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
889 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
890 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
891 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
892 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
893 | L_var1 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
894 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
895 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
896 | L_var2 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
897 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
898 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
899 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
900 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
901 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
902 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
903 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
904 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
905 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
906 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
907 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
908 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
909 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
910 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
911 Word32 L_add (Word32 L_var1, Word32 L_var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
912 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
913 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
914 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
915 L_var_out = L_var1 + L_var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
916 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
917 if (((L_var1 ^ L_var2) & MIN_32) == 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
918 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
919 if ((L_var_out ^ L_var1) & MIN_32) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
920 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
921 L_var_out = (L_var1 < 0) ? MIN_32 : MAX_32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
922 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
923 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
924 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
925 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
926 multiCounter[currCounter].L_add++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
927 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
928 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
929 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
930 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
931 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
932 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
933 | Function Name : L_sub | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
934 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
935 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
936 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
937 | 32 bits subtraction of the two 32 bits variables (L_var1-L_var2) with | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
938 | overflow control and saturation; the result is set at +2147483647 when | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
939 | overflow occurs or at -2147483648 when underflow occurs. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
940 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
941 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
942 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
943 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
944 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
945 | L_var1 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
946 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
947 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
948 | L_var2 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
949 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
950 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
951 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
952 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
953 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
954 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
955 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
956 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
957 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
958 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
959 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
960 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
961 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
962 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
963 Word32 L_sub (Word32 L_var1, Word32 L_var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
964 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
965 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
966 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
967 L_var_out = L_var1 - L_var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
968 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
969 if (((L_var1 ^ L_var2) & MIN_32) != 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
970 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
971 if ((L_var_out ^ L_var1) & MIN_32) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
972 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
973 L_var_out = (L_var1 < 0L) ? MIN_32 : MAX_32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
974 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
975 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
976 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
977 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
978 multiCounter[currCounter].L_sub++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
979 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
980 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
981 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
982 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
983 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
984 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
985 | Function Name : L_add_c | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
986 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
987 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
988 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
989 | Performs 32 bits addition of the two 32 bits variables (L_var1+L_var2+C)| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
990 | with carry. No saturation. Generate carry and Overflow values. The car- | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
991 | ry and overflow values are binary variables which can be tested and as- | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
992 | signed values. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
993 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
994 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
995 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
996 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
997 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
998 | L_var1 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
999 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1000 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1001 | L_var2 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1002 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1003 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1004 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1005 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1006 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1007 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1008 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1009 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1010 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1011 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1012 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1013 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1014 | Caution : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1015 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1016 | In some cases the Carry flag has to be cleared or set before using | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1017 | operators which take into account its value. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1018 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1019 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1020 Word32 L_add_c (Word32 L_var1, Word32 L_var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1021 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1022 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1023 Word32 L_test; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1024 Flag carry_int = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1025 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1026 L_var_out = L_var1 + L_var2 + Carry; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1027 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1028 L_test = L_var1 + L_var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1029 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1030 if ((L_var1 > 0) && (L_var2 > 0) && (L_test < 0)) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1031 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1032 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1033 carry_int = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1034 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1035 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1036 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1037 if ((L_var1 < 0) && (L_var2 < 0)) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1038 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1039 if (L_test >= 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1040 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1041 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1042 carry_int = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1043 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1044 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1045 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1046 Overflow = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1047 carry_int = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1048 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1049 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1050 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1051 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1052 if (((L_var1 ^ L_var2) < 0) && (L_test >= 0)) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1053 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1054 Overflow = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1055 carry_int = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1056 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1057 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1058 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1059 Overflow = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1060 carry_int = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1061 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1062 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1063 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1064 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1065 if (Carry) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1066 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1067 if (L_test == MAX_32) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1068 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1069 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1070 Carry = carry_int; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1071 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1072 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1073 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1074 if (L_test == (Word32) 0xFFFFFFFFL) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1075 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1076 Carry = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1077 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1078 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1079 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1080 Carry = carry_int; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1081 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1082 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1083 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1084 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1085 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1086 Carry = carry_int; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1087 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1088 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1089 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1090 multiCounter[currCounter].L_add_c++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1091 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1092 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1093 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1094 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1095 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1096 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1097 | Function Name : L_sub_c | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1098 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1099 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1100 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1101 | Performs 32 bits subtraction of the two 32 bits variables with carry | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1102 | (borrow) : L_var1-L_var2-C. No saturation. Generate carry and Overflow | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1103 | values. The carry and overflow values are binary variables which can | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1104 | be tested and assigned values. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1105 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1106 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1107 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1108 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1109 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1110 | L_var1 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1111 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1112 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1113 | L_var2 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1114 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1115 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1116 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1117 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1118 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1119 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1120 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1121 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1122 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1123 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1124 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1125 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1126 | Caution : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1127 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1128 | In some cases the Carry flag has to be cleared or set before using | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1129 | operators which take into account its value. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1130 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1131 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1132 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1133 Word32 L_sub_c (Word32 L_var1, Word32 L_var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1134 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1135 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1136 Word32 L_test; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1137 Flag carry_int = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1138 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1139 if (Carry) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1140 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1141 Carry = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1142 if (L_var2 != MIN_32) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1143 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1144 L_var_out = L_add_c (L_var1, -L_var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1145 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1146 multiCounter[currCounter].L_add_c--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1147 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1148 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1149 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1150 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1151 L_var_out = L_var1 - L_var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1152 if (L_var1 > 0L) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1153 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1154 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1155 Carry = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1156 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1157 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1158 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1159 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1160 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1161 L_var_out = L_var1 - L_var2 - (Word32) 0X00000001L; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1162 L_test = L_var1 - L_var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1163 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1164 if ((L_test < 0) && (L_var1 > 0) && (L_var2 < 0)) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1165 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1166 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1167 carry_int = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1168 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1169 else if ((L_test > 0) && (L_var1 < 0) && (L_var2 > 0)) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1170 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1171 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1172 carry_int = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1173 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1174 else if ((L_test > 0) && ((L_var1 ^ L_var2) > 0)) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1175 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1176 Overflow = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1177 carry_int = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1178 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1179 if (L_test == MIN_32) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1180 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1181 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1182 Carry = carry_int; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1183 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1184 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1185 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1186 Carry = carry_int; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1187 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1188 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1189 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1190 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1191 multiCounter[currCounter].L_sub_c++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1192 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1193 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1194 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1195 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1196 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1197 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1198 | Function Name : L_negate | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1199 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1200 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1201 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1202 | Negate the 32 bit variable L_var1 with saturation; saturate in the case | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1203 | where input is -2147483648 (0x8000 0000). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1204 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1205 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1206 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1207 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1208 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1209 | L_var1 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1210 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1211 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1212 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1213 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1214 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1215 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1216 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1217 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1218 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1219 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1220 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1221 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1222 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1223 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1224 Word32 L_negate (Word32 L_var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1225 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1226 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1227 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1228 L_var_out = (L_var1 == MIN_32) ? MAX_32 : -L_var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1229 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1230 multiCounter[currCounter].L_negate++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1231 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1232 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1233 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1234 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1235 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1236 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1237 | Function Name : mult_r | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1238 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1239 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1240 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1241 | Same as mult with rounding, i.e.: | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1242 | mult_r(var1,var2) = extract_l(L_shr(((var1 * var2) + 16384),15)) and | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1243 | mult_r(-32768,-32768) = 32767. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1244 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1245 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1246 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1247 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1248 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1249 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1250 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1251 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1252 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1253 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1254 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1255 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1256 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1257 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1258 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1259 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1260 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1261 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1262 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1263 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1264 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1265 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1266 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1267 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1268 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1269 Word16 mult_r (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1270 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1271 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1272 Word32 L_product_arr; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1273 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1274 L_product_arr = (Word32) var1 *(Word32) var2; /* product */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1275 L_product_arr += (Word32) 0x00004000L; /* round */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1276 L_product_arr &= (Word32) 0xffff8000L; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1277 L_product_arr >>= 15; /* shift */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1278 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1279 if (L_product_arr & (Word32) 0x00010000L) /* sign extend when necessary */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1280 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1281 L_product_arr |= (Word32) 0xffff0000L; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1282 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1283 var_out = saturate (L_product_arr); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1284 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1285 multiCounter[currCounter].mult_r++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1286 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1287 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1288 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1289 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1290 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1291 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1292 | Function Name : L_shl | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1293 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1294 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1295 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1296 | Arithmetically shift the 32 bit input L_var1 left var2 positions. Zero | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1297 | fill the var2 LSB of the result. If var2 is negative, arithmetically | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1298 | shift L_var1 right by -var2 with sign extension. Saturate the result in | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1299 | case of underflows or overflows. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1300 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1301 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1302 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1303 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1304 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1305 | L_var1 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1306 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1307 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1308 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1309 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1310 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1311 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1312 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1313 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1314 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1315 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1316 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1317 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1318 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1319 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1320 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1321 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1322 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1323 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1324 Word32 L_shl (Word32 L_var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1325 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1326 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1327 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1328 if (var2 <= 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1329 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1330 if (var2 < -32) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1331 var2 = -32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1332 L_var_out = L_shr (L_var1, -var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1333 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1334 multiCounter[currCounter].L_shr--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1335 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1336 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1337 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1338 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1339 for (; var2 > 0; var2--) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1340 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1341 if (L_var1 > (Word32) 0X3fffffffL) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1342 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1343 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1344 L_var_out = MAX_32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1345 break; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1346 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1347 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1348 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1349 if (L_var1 < (Word32) 0xc0000000L) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1350 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1351 Overflow = 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1352 L_var_out = MIN_32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1353 break; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1354 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1355 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1356 L_var1 *= 2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1357 L_var_out = L_var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1358 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1359 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1360 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1361 multiCounter[currCounter].L_shl++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1362 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1363 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1364 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1365 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1366 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1367 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1368 | Function Name : L_shr | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1369 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1370 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1371 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1372 | Arithmetically shift the 32 bit input L_var1 right var2 positions with | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1373 | sign extension. If var2 is negative, arithmetically shift L_var1 left | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1374 | by -var2 and zero fill the -var2 LSB of the result. Saturate the result | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1375 | in case of underflows or overflows. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1376 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1377 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1378 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1379 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1380 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1381 | L_var1 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1382 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1383 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1384 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1385 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1386 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1387 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1388 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1389 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1390 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1391 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1392 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1393 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1394 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1395 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1396 | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1397 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1398 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1399 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1400 Word32 L_shr (Word32 L_var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1401 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1402 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1403 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1404 if (var2 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1405 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1406 if (var2 < -32) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1407 var2 = -32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1408 L_var_out = L_shl (L_var1, -var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1409 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1410 multiCounter[currCounter].L_shl--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1411 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1412 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1413 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1414 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1415 if (var2 >= 31) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1416 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1417 L_var_out = (L_var1 < 0L) ? -1 : 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1418 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1419 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1420 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1421 if (L_var1 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1422 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1423 L_var_out = ~((~L_var1) >> var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1424 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1425 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1426 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1427 L_var_out = L_var1 >> var2; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1428 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1429 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1430 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1431 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1432 multiCounter[currCounter].L_shr++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1433 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1434 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1435 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1436 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1437 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1438 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1439 | Function Name : shr_r | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1440 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1441 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1442 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1443 | Same as shr(var1,var2) but with rounding. Saturate the result in case of| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1444 | underflows or overflows : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1445 | - If var2 is greater than zero : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1446 | if (sub(shl(shr(var1,var2),1),shr(var1,sub(var2,1)))) | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1447 | is equal to zero | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1448 | then | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1449 | shr_r(var1,var2) = shr(var1,var2) | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1450 | else | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1451 | shr_r(var1,var2) = add(shr(var1,var2),1) | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1452 | - If var2 is less than or equal to zero : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1453 | shr_r(var1,var2) = shr(var1,var2). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1454 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1455 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1456 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1457 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1458 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1459 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1460 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1461 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1462 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1463 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1464 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1465 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1466 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1467 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1468 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1469 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1470 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1471 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1472 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1473 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1474 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1475 | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1476 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1477 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1478 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1479 Word16 shr_r (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1480 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1481 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1482 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1483 if (var2 > 15) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1484 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1485 var_out = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1486 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1487 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1488 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1489 var_out = shr (var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1490 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1491 multiCounter[currCounter].shr--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1492 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1493 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1494 if (var2 > 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1495 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1496 if ((var1 & ((Word16) 1 << (var2 - 1))) != 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1497 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1498 var_out++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1499 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1500 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1501 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1502 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1503 multiCounter[currCounter].shr_r++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1504 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1505 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1506 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1507 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1508 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1509 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1510 | Function Name : mac_r | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1511 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1512 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1513 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1514 | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1515 | result to L_var3 with saturation. Round the LS 16 bits of the result | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1516 | into the MS 16 bits with saturation and shift the result right by 16. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1517 | Return a 16 bit result. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1518 | mac_r(L_var3,var1,var2) = round(L_mac(L_var3,var1,var2)) | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1519 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1520 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1521 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1522 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1523 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1524 | L_var3 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1525 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1526 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1527 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1528 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1529 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1530 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1531 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1532 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1533 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1534 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1535 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1536 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1537 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1538 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1539 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1540 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1541 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1542 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1543 | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1544 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1545 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1546 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1547 Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1548 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1549 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1550 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1551 L_var3 = L_mac (L_var3, var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1552 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1553 multiCounter[currCounter].L_mac--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1554 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1555 L_var3 = L_add (L_var3, (Word32) 0x00008000L); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1556 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1557 multiCounter[currCounter].L_add--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1558 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1559 var_out = extract_h (L_var3); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1560 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1561 multiCounter[currCounter].extract_h--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1562 multiCounter[currCounter].mac_r++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1563 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1564 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1565 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1566 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1567 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1568 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1569 | Function Name : msu_r | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1570 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1571 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1572 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1573 | Multiply var1 by var2 and shift the result left by 1. Subtract the 32 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1574 | bit result to L_var3 with saturation. Round the LS 16 bits of the res- | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1575 | ult into the MS 16 bits with saturation and shift the result right by | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1576 | 16. Return a 16 bit result. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1577 | msu_r(L_var3,var1,var2) = round(L_msu(L_var3,var1,var2)) | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1578 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1579 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1580 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1581 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1582 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1583 | L_var3 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1584 | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1585 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1586 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1587 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1588 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1589 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1590 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1591 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1592 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1593 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1594 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1595 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1596 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1597 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1598 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1599 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1600 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1601 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1602 | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1603 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1604 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1605 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1606 Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1607 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1608 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1609 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1610 L_var3 = L_msu (L_var3, var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1611 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1612 multiCounter[currCounter].L_msu--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1613 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1614 L_var3 = L_add (L_var3, (Word32) 0x00008000L); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1615 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1616 multiCounter[currCounter].L_add--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1617 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1618 var_out = extract_h (L_var3); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1619 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1620 multiCounter[currCounter].extract_h--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1621 multiCounter[currCounter].msu_r++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1622 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1623 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1624 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1625 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1626 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1627 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1628 | Function Name : L_deposit_h | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1629 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1630 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1631 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1632 | Deposit the 16 bit var1 into the 16 MS bits of the 32 bit output. The | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1633 | 16 LS bits of the output are zeroed. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1634 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1635 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1636 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1637 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1638 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1639 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1640 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1641 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1642 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1643 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1644 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1645 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1646 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1647 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1648 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1649 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1650 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1651 | range : 0x8000 0000 <= var_out <= 0x7fff 0000. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1652 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1653 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1654 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1655 Word32 L_deposit_h (Word16 var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1656 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1657 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1658 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1659 L_var_out = (Word32) var1 << 16; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1660 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1661 multiCounter[currCounter].L_deposit_h++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1662 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1663 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1664 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1665 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1666 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1667 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1668 | Function Name : L_deposit_l | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1669 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1670 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1671 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1672 | Deposit the 16 bit var1 into the 16 LS bits of the 32 bit output. The | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1673 | 16 MS bits of the output are sign extended. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1674 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1675 | Complexity weight : 2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1676 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1677 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1678 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1679 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1680 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1681 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1682 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1683 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1684 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1685 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1686 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1687 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1688 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1689 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1690 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1691 | range : 0xFFFF 8000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1692 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1693 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1694 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1695 Word32 L_deposit_l (Word16 var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1696 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1697 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1698 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1699 L_var_out = (Word32) var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1700 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1701 multiCounter[currCounter].L_deposit_l++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1702 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1703 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1704 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1705 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1706 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1707 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1708 | Function Name : L_shr_r | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1709 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1710 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1711 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1712 | Same as L_shr(L_var1,var2) but with rounding. Saturate the result in | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1713 | case of underflows or overflows : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1714 | - If var2 is greater than zero : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1715 | if (L_sub(L_shl(L_shr(L_var1,var2),1),L_shr(L_var1,sub(var2,1))))| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1716 | is equal to zero | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1717 | then | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1718 | L_shr_r(L_var1,var2) = L_shr(L_var1,var2) | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1719 | else | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1720 | L_shr_r(L_var1,var2) = L_add(L_shr(L_var1,var2),1) | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1721 | - If var2 is less than or equal to zero : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1722 | L_shr_r(L_var1,var2) = L_shr(L_var1,var2). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1723 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1724 | Complexity weight : 3 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1725 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1726 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1727 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1728 | L_var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1729 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1730 | range : 0x8000 0000 <= var1 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1731 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1732 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1733 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1734 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1735 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1736 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1737 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1738 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1739 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1740 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1741 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1742 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1743 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1744 | range : 0x8000 0000 <= var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1745 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1746 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1747 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1748 Word32 L_shr_r (Word32 L_var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1749 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1750 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1751 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1752 if (var2 > 31) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1753 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1754 L_var_out = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1755 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1756 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1757 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1758 L_var_out = L_shr (L_var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1759 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1760 multiCounter[currCounter].L_shr--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1761 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1762 if (var2 > 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1763 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1764 if ((L_var1 & ((Word32) 1 << (var2 - 1))) != 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1765 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1766 L_var_out++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1767 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1768 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1769 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1770 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1771 multiCounter[currCounter].L_shr_r++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1772 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1773 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1774 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1775 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1776 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1777 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1778 | Function Name : L_abs | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1779 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1780 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1781 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1782 | Absolute value of L_var1; Saturate in case where the input is | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1783 | -214783648 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1784 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1785 | Complexity weight : 3 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1786 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1787 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1788 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1789 | L_var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1790 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1791 | range : 0x8000 0000 <= var1 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1792 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1793 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1794 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1795 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1796 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1797 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1798 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1799 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1800 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1801 | range : 0x0000 0000 <= var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1802 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1803 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1804 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1805 Word32 L_abs (Word32 L_var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1806 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1807 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1808 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1809 if (L_var1 == MIN_32) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1810 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1811 L_var_out = MAX_32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1812 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1813 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1814 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1815 if (L_var1 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1816 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1817 L_var_out = -L_var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1818 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1819 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1820 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1821 L_var_out = L_var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1822 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1823 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1824 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1825 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1826 multiCounter[currCounter].L_abs++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1827 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1828 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1829 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1830 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1831 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1832 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1833 | Function Name : L_sat | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1834 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1835 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1836 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1837 | 32 bit L_var1 is set to 2147483647 if an overflow occured or to | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1838 | -2147483648 if an underflow occured on the most recent L_add_c, | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1839 | L_sub_c, L_macNs or L_msuNs operations. The carry and overflow values | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1840 | are binary values which can be tested and assigned values. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1841 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1842 | Complexity weight : 4 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1843 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1844 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1845 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1846 | L_var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1847 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1848 | range : 0x8000 0000 <= var1 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1849 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1850 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1851 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1852 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1853 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1854 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1855 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1856 | L_var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1857 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1858 | range : 0x8000 0000 <= var_out <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1859 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1860 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1861 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1862 Word32 L_sat (Word32 L_var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1863 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1864 Word32 L_var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1865 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1866 L_var_out = L_var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1867 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1868 if (Overflow) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1869 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1870 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1871 if (Carry) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1872 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1873 L_var_out = MIN_32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1874 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1875 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1876 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1877 L_var_out = MAX_32; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1878 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1879 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1880 Carry = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1881 Overflow = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1882 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1883 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1884 multiCounter[currCounter].L_sat++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1885 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1886 return (L_var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1887 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1888 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1889 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1890 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1891 | Function Name : norm_s | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1892 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1893 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1894 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1895 | Produces the number of left shift needed to normalize the 16 bit varia- | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1896 | ble var1 for positive values on the interval with minimum of 16384 and | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1897 | maximum of 32767, and for negative values on the interval with minimum | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1898 | of -32768 and maximum of -16384; in order to normalize the result, the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1899 | following operation must be done : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1900 | norm_var1 = shl(var1,norm_s(var1)). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1901 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1902 | Complexity weight : 15 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1903 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1904 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1905 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1906 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1907 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1908 | range : 0xffff 8000 <= var1 <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1909 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1910 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1911 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1912 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1913 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1914 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1915 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1916 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1917 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1918 | range : 0x0000 0000 <= var_out <= 0x0000 000f. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1919 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1920 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1921 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1922 Word16 norm_s (Word16 var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1923 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1924 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1925 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1926 if (var1 == 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1927 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1928 var_out = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1929 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1930 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1931 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1932 if (var1 == (Word16) 0xffff) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1933 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1934 var_out = 15; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1935 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1936 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1937 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1938 if (var1 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1939 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1940 var1 = ~var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1941 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1942 for (var_out = 0; var1 < 0x4000; var_out++) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1943 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1944 var1 <<= 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1945 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1946 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1947 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1948 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1949 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1950 multiCounter[currCounter].norm_s++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1951 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1952 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1953 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1954 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1955 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1956 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1957 | Function Name : div_s | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1958 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1959 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1960 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1961 | Produces a result which is the fractional integer division of var1 by | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1962 | var2; var1 and var2 must be positive and var2 must be greater or equal | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1963 | to var1; the result is positive (leading bit equal to 0) and truncated | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1964 | to 16 bits. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1965 | If var1 = var2 then div(var1,var2) = 32767. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1966 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1967 | Complexity weight : 18 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1968 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1969 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1970 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1971 | var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1972 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1973 | range : 0x0000 0000 <= var1 <= var2 and var2 != 0. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1974 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1975 | var2 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1976 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1977 | range : var1 <= var2 <= 0x0000 7fff and var2 != 0. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1978 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1979 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1980 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1981 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1982 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1983 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1984 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1985 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1986 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1987 | range : 0x0000 0000 <= var_out <= 0x0000 7fff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1988 | It's a Q15 value (point between b15 and b14). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1989 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1990 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1991 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1992 Word16 div_s (Word16 var1, Word16 var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1993 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1994 Word16 var_out = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1995 Word16 iteration; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1996 Word32 L_num; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1997 Word32 L_denom; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1998 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1999 #if 0 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2000 if ((var1 > var2) || (var1 < 0) || (var2 < 0)) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2001 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2002 printf ("Division Error var1=%d var2=%d\n", var1, var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2003 abort(); /* exit (0); */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2004 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2005 if (var2 == 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2006 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2007 printf ("Division by 0, Fatal error \n"); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2008 abort(); /* exit (0); */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2009 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2010 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2011 if (var1 == 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2012 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2013 var_out = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2014 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2015 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2016 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2017 if (var1 == var2) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2018 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2019 var_out = MAX_16; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2020 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2021 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2022 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2023 L_num = L_deposit_l (var1); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2024 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2025 multiCounter[currCounter].L_deposit_l--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2026 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2027 L_denom = L_deposit_l (var2); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2028 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2029 multiCounter[currCounter].L_deposit_l--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2030 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2031 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2032 for (iteration = 0; iteration < 15; iteration++) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2033 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2034 var_out <<= 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2035 L_num <<= 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2036 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2037 if (L_num >= L_denom) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2038 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2039 L_num = L_sub (L_num, L_denom); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2040 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2041 multiCounter[currCounter].L_sub--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2042 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2043 var_out = add (var_out, 1); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2044 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2045 multiCounter[currCounter].add--; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2046 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2047 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2048 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2049 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2050 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2051 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2052 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2053 multiCounter[currCounter].div_s++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2054 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2055 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2056 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2057 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2058 /*___________________________________________________________________________ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2059 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2060 | Function Name : norm_l | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2061 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2062 | Purpose : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2063 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2064 | Produces the number of left shifts needed to normalize the 32 bit varia-| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2065 | ble L_var1 for positive values on the interval with minimum of | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2066 | 1073741824 and maximum of 2147483647, and for negative values on the in-| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2067 | terval with minimum of -2147483648 and maximum of -1073741824; in order | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2068 | to normalize the result, the following operation must be done : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2069 | norm_L_var1 = L_shl(L_var1,norm_l(L_var1)). | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2070 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2071 | Complexity weight : 30 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2072 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2073 | Inputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2074 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2075 | L_var1 | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2076 | 32 bit long signed integer (Word32) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2077 | range : 0x8000 0000 <= var1 <= 0x7fff ffff. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2078 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2079 | Outputs : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2080 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2081 | none | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2082 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2083 | Return Value : | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2084 | | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2085 | var_out | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2086 | 16 bit short signed integer (Word16) whose value falls in the | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2087 | range : 0x0000 0000 <= var_out <= 0x0000 001f. | |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2088 |___________________________________________________________________________| |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2089 */ |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2090 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2091 Word16 norm_l (Word32 L_var1) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2092 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2093 Word16 var_out; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2094 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2095 if (L_var1 == 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2096 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2097 var_out = 0; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2098 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2099 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2100 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2101 if (L_var1 == (Word32) 0xffffffffL) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2102 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2103 var_out = 31; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2104 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2105 else |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2106 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2107 if (L_var1 < 0) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2108 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2109 L_var1 = ~L_var1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2110 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2111 for (var_out = 0; L_var1 < (Word32) 0x40000000L; var_out++) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2112 { |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2113 L_var1 <<= 1; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2114 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2115 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2116 } |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2117 |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2118 #if (WMOPS) |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2119 multiCounter[currCounter].norm_l++; |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2120 #endif |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2121 return (var_out); |
57b4053559ff
libtwamr: beginning of project
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2122 } |