1*f3782652STreehugger Robot /*
2*f3782652STreehugger Robot
3*f3782652STreehugger Robot Copyright (c) 2009, 2010, 2011 STMicroelectronics
4*f3782652STreehugger Robot Written by Christophe Lyon
5*f3782652STreehugger Robot
6*f3782652STreehugger Robot Permission is hereby granted, free of charge, to any person obtaining a copy
7*f3782652STreehugger Robot of this software and associated documentation files (the "Software"), to deal
8*f3782652STreehugger Robot in the Software without restriction, including without limitation the rights
9*f3782652STreehugger Robot to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10*f3782652STreehugger Robot copies of the Software, and to permit persons to whom the Software is
11*f3782652STreehugger Robot furnished to do so, subject to the following conditions:
12*f3782652STreehugger Robot
13*f3782652STreehugger Robot The above copyright notice and this permission notice shall be included in
14*f3782652STreehugger Robot all copies or substantial portions of the Software.
15*f3782652STreehugger Robot
16*f3782652STreehugger Robot THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*f3782652STreehugger Robot IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*f3782652STreehugger Robot FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19*f3782652STreehugger Robot AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*f3782652STreehugger Robot LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21*f3782652STreehugger Robot OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22*f3782652STreehugger Robot THE SOFTWARE.
23*f3782652STreehugger Robot
24*f3782652STreehugger Robot */
25*f3782652STreehugger Robot
26*f3782652STreehugger Robot #if defined(__cplusplus)
27*f3782652STreehugger Robot #include <cstdio>
28*f3782652STreehugger Robot #include <cstdint>
29*f3782652STreehugger Robot #else
30*f3782652STreehugger Robot #include <stdio.h>
31*f3782652STreehugger Robot #if defined(_MSC_VER)
32*f3782652STreehugger Robot #include "msstdint.h"
33*f3782652STreehugger Robot #else
34*f3782652STreehugger Robot #include <stdint.h>
35*f3782652STreehugger Robot #endif
36*f3782652STreehugger Robot #endif
37*f3782652STreehugger Robot
38*f3782652STreehugger Robot #if defined(__arm__) || defined(__aarch64__)
39*f3782652STreehugger Robot #include <dspfns.h>
40*f3782652STreehugger Robot #else
41*f3782652STreehugger Robot #include "stm-dspfns.h"
42*f3782652STreehugger Robot #endif
43*f3782652STreehugger Robot
44*f3782652STreehugger Robot extern FILE* ref_file;
45*f3782652STreehugger Robot
46*f3782652STreehugger Robot #define __xSTR(X) #X
47*f3782652STreehugger Robot #define __STR(X) __xSTR(X)
48*f3782652STreehugger Robot
49*f3782652STreehugger Robot #define FN(X) X, __STR(X)
50*f3782652STreehugger Robot
51*f3782652STreehugger Robot typedef int32_t func32_32_32_ptr(int32_t, int32_t);
52*f3782652STreehugger Robot typedef int16_t func16_32_ptr(int32_t);
53*f3782652STreehugger Robot typedef int32_t func32_32_16_16_ptr(int32_t, int16_t, int16_t);
54*f3782652STreehugger Robot
test_16_fn_32(func16_32_ptr func,const char * func_name,int init_Overflow,int init_Carry)55*f3782652STreehugger Robot void test_16_fn_32(func16_32_ptr func, const char* func_name,
56*f3782652STreehugger Robot int init_Overflow, int init_Carry)
57*f3782652STreehugger Robot {
58*f3782652STreehugger Robot int32_t svar32_a;
59*f3782652STreehugger Robot int16_t svar16_a;
60*f3782652STreehugger Robot
61*f3782652STreehugger Robot fprintf(ref_file, "Checking %s with input Overflow=%d and input Carry=%d\n",
62*f3782652STreehugger Robot func_name, init_Overflow, init_Carry);
63*f3782652STreehugger Robot
64*f3782652STreehugger Robot svar32_a = 1;
65*f3782652STreehugger Robot Overflow = init_Overflow;
66*f3782652STreehugger Robot Carry = init_Carry;
67*f3782652STreehugger Robot svar16_a = func(svar32_a);
68*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x) = %#x overflow %d carry %d\n",
69*f3782652STreehugger Robot func_name, svar32_a, svar16_a, Overflow, Carry);
70*f3782652STreehugger Robot
71*f3782652STreehugger Robot svar32_a = -1;
72*f3782652STreehugger Robot Overflow = init_Overflow;
73*f3782652STreehugger Robot Carry = init_Carry;
74*f3782652STreehugger Robot svar16_a = func(svar32_a);
75*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x) = %#x overflow %d carry %d\n",
76*f3782652STreehugger Robot func_name, svar32_a, svar16_a, Overflow, Carry);
77*f3782652STreehugger Robot
78*f3782652STreehugger Robot svar32_a = 32768;
79*f3782652STreehugger Robot Overflow = init_Overflow;
80*f3782652STreehugger Robot Carry = init_Carry;
81*f3782652STreehugger Robot svar16_a = func(svar32_a);
82*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x) = %#x overflow %d carry %d\n",
83*f3782652STreehugger Robot func_name, svar32_a, svar16_a, Overflow, Carry);
84*f3782652STreehugger Robot
85*f3782652STreehugger Robot svar32_a = -32768;
86*f3782652STreehugger Robot Overflow = init_Overflow;
87*f3782652STreehugger Robot Carry = init_Carry;
88*f3782652STreehugger Robot svar16_a = func(svar32_a);
89*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x) = %#x overflow %d carry %d\n",
90*f3782652STreehugger Robot func_name, svar32_a, svar16_a, Overflow, Carry);
91*f3782652STreehugger Robot
92*f3782652STreehugger Robot svar32_a = -32769;
93*f3782652STreehugger Robot Overflow = init_Overflow;
94*f3782652STreehugger Robot Carry = init_Carry;
95*f3782652STreehugger Robot svar16_a = func(svar32_a);
96*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x) = %#x overflow %d carry %d\n",
97*f3782652STreehugger Robot func_name, svar32_a, svar16_a, Overflow, Carry);
98*f3782652STreehugger Robot }
99*f3782652STreehugger Robot
test_32_fn_32_32(func32_32_32_ptr func,const char * func_name,int init_Overflow,int init_Carry)100*f3782652STreehugger Robot void test_32_fn_32_32(func32_32_32_ptr func, const char* func_name,
101*f3782652STreehugger Robot int init_Overflow, int init_Carry)
102*f3782652STreehugger Robot {
103*f3782652STreehugger Robot int32_t svar32_a, svar32_b, svar32_c;
104*f3782652STreehugger Robot
105*f3782652STreehugger Robot fprintf(ref_file, "Checking %s with input Overflow=%d and input Carry=%d\n",
106*f3782652STreehugger Robot func_name, init_Overflow, init_Carry);
107*f3782652STreehugger Robot
108*f3782652STreehugger Robot svar32_a = 1;
109*f3782652STreehugger Robot svar32_b = 2;
110*f3782652STreehugger Robot Overflow = init_Overflow;
111*f3782652STreehugger Robot Carry = init_Carry;
112*f3782652STreehugger Robot svar32_c = func(svar32_a, svar32_b);
113*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x) = %#x overflow %d carry %d\n",
114*f3782652STreehugger Robot func_name, svar32_a, svar32_b, svar32_c, Overflow, Carry);
115*f3782652STreehugger Robot
116*f3782652STreehugger Robot svar32_a = -1;
117*f3782652STreehugger Robot svar32_b = -2;
118*f3782652STreehugger Robot Overflow = init_Overflow;
119*f3782652STreehugger Robot Carry = init_Carry;
120*f3782652STreehugger Robot svar32_c = func(svar32_a, svar32_b);
121*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x) = %#x overflow %d carry %d\n",
122*f3782652STreehugger Robot func_name, svar32_a, svar32_b, svar32_c, Overflow, Carry);
123*f3782652STreehugger Robot
124*f3782652STreehugger Robot svar32_a = -1;
125*f3782652STreehugger Robot svar32_b = 2;
126*f3782652STreehugger Robot Overflow = init_Overflow;
127*f3782652STreehugger Robot Carry = init_Carry;
128*f3782652STreehugger Robot svar32_c = func(svar32_a, svar32_b);
129*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x) = %#x overflow %d carry %d\n",
130*f3782652STreehugger Robot func_name, svar32_a, svar32_b, svar32_c, Overflow, Carry);
131*f3782652STreehugger Robot
132*f3782652STreehugger Robot svar32_a = 0x7000;
133*f3782652STreehugger Robot svar32_b = 0x7000;
134*f3782652STreehugger Robot Overflow = init_Overflow;
135*f3782652STreehugger Robot Carry = init_Carry;
136*f3782652STreehugger Robot svar32_c = func(svar32_a, svar32_b);
137*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x) = %#x overflow %d carry %d\n",
138*f3782652STreehugger Robot func_name, svar32_a, svar32_b, svar32_c, Overflow, Carry);
139*f3782652STreehugger Robot
140*f3782652STreehugger Robot svar32_a = 0x8FFF;
141*f3782652STreehugger Robot svar32_b = 0x8FFF;
142*f3782652STreehugger Robot Overflow = init_Overflow;
143*f3782652STreehugger Robot Carry = init_Carry;
144*f3782652STreehugger Robot svar32_c = func(svar32_a, svar32_b);
145*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x) = %#x overflow %d carry %d\n",
146*f3782652STreehugger Robot func_name, svar32_a, svar32_b, svar32_c, Overflow, Carry);
147*f3782652STreehugger Robot
148*f3782652STreehugger Robot svar32_a = 0x70000000;
149*f3782652STreehugger Robot svar32_b = 0x70000000;
150*f3782652STreehugger Robot Overflow = init_Overflow;
151*f3782652STreehugger Robot Carry = init_Carry;
152*f3782652STreehugger Robot svar32_c = func(svar32_a, svar32_b);
153*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x) = %#x overflow %d carry %d\n",
154*f3782652STreehugger Robot func_name, svar32_a, svar32_b, svar32_c, Overflow, Carry);
155*f3782652STreehugger Robot
156*f3782652STreehugger Robot svar32_a = 0x8FFFFFFF;
157*f3782652STreehugger Robot svar32_b = 0x8FFFFFFF;
158*f3782652STreehugger Robot Overflow = init_Overflow;
159*f3782652STreehugger Robot Carry = init_Carry;
160*f3782652STreehugger Robot svar32_c = func(svar32_a, svar32_b);
161*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x) = %#x overflow %d carry %d\n",
162*f3782652STreehugger Robot func_name, svar32_a, svar32_b, svar32_c, Overflow, Carry);
163*f3782652STreehugger Robot
164*f3782652STreehugger Robot svar32_a = 0x8FFFFFFF;
165*f3782652STreehugger Robot svar32_b = 0xFFFFFFFF;
166*f3782652STreehugger Robot Overflow = init_Overflow;
167*f3782652STreehugger Robot Carry = init_Carry;
168*f3782652STreehugger Robot svar32_c = func(svar32_a, svar32_b);
169*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x) = %#x overflow %d carry %d\n",
170*f3782652STreehugger Robot func_name, svar32_a, svar32_b, svar32_c, Overflow, Carry);
171*f3782652STreehugger Robot }
172*f3782652STreehugger Robot
test_32_fn_32_16_16(func32_32_16_16_ptr func,const char * func_name,int init_Overflow,int init_Carry)173*f3782652STreehugger Robot void test_32_fn_32_16_16(func32_32_16_16_ptr func, const char* func_name,
174*f3782652STreehugger Robot int init_Overflow, int init_Carry)
175*f3782652STreehugger Robot {
176*f3782652STreehugger Robot int32_t svar32_a, svar32_b;
177*f3782652STreehugger Robot int16_t svar16_a, svar16_b;
178*f3782652STreehugger Robot
179*f3782652STreehugger Robot fprintf(ref_file, "Checking %s with input Overflow=%d and input Carry=%d\n",
180*f3782652STreehugger Robot func_name, init_Overflow, init_Carry);
181*f3782652STreehugger Robot
182*f3782652STreehugger Robot svar16_a = 2;
183*f3782652STreehugger Robot svar16_b = 2;
184*f3782652STreehugger Robot svar32_a = 0x1234;
185*f3782652STreehugger Robot Overflow = 0;
186*f3782652STreehugger Robot Carry = init_Carry;
187*f3782652STreehugger Robot svar32_b = func(svar32_a, svar16_a, svar16_b);
188*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x, %#x) = %#x overflow %d carry %d\n",
189*f3782652STreehugger Robot func_name, svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
190*f3782652STreehugger Robot
191*f3782652STreehugger Robot svar16_a = -1;
192*f3782652STreehugger Robot svar16_b = -1;
193*f3782652STreehugger Robot Overflow = 0;
194*f3782652STreehugger Robot Carry = init_Carry;
195*f3782652STreehugger Robot svar32_b = func(svar32_a, svar16_a, svar16_b);
196*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x, %#x) = %#x overflow %d carry %d\n",
197*f3782652STreehugger Robot func_name, svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
198*f3782652STreehugger Robot
199*f3782652STreehugger Robot svar16_a = 0x8000;
200*f3782652STreehugger Robot svar16_b = 0x8000;
201*f3782652STreehugger Robot Overflow = 0;
202*f3782652STreehugger Robot Carry = init_Carry;
203*f3782652STreehugger Robot svar32_b = func(svar32_a, svar16_a, svar16_b);
204*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x, %#x) = %#x overflow %d carry %d\n",
205*f3782652STreehugger Robot func_name, svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
206*f3782652STreehugger Robot
207*f3782652STreehugger Robot svar16_a = 0x8000;
208*f3782652STreehugger Robot svar16_b = 0x8000;
209*f3782652STreehugger Robot Overflow = 0;
210*f3782652STreehugger Robot Carry = init_Carry;
211*f3782652STreehugger Robot svar32_a = -1;
212*f3782652STreehugger Robot svar32_b = func(svar32_a, svar16_a, svar16_b);
213*f3782652STreehugger Robot fprintf(ref_file, "%s(%#x, %#x, %#x) = %#x overflow %d carry %d\n",
214*f3782652STreehugger Robot func_name, svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
215*f3782652STreehugger Robot }
216*f3782652STreehugger Robot
exec_dspfns1(int init_Overflow,int init_Carry)217*f3782652STreehugger Robot void exec_dspfns1 (int init_Overflow, int init_Carry)
218*f3782652STreehugger Robot {
219*f3782652STreehugger Robot int32_t svar32_a, svar32_b, svar32_c;
220*f3782652STreehugger Robot int16_t svar16_a, svar16_b, svar16_c;
221*f3782652STreehugger Robot
222*f3782652STreehugger Robot
223*f3782652STreehugger Robot fprintf(ref_file, "\n\nDSP FNS (non-NEON/ITU) intrinsics with input Overflow=%d and input Carry=%d\n", init_Overflow, init_Carry);
224*f3782652STreehugger Robot
225*f3782652STreehugger Robot /* saturate */
226*f3782652STreehugger Robot /* int16_t saturate(int32_t x) */
227*f3782652STreehugger Robot test_16_fn_32(FN(saturate), init_Overflow, init_Carry);
228*f3782652STreehugger Robot
229*f3782652STreehugger Robot
230*f3782652STreehugger Robot /* add */
231*f3782652STreehugger Robot /* int16_t add(int16_t x, int16_t y) */
232*f3782652STreehugger Robot svar16_a = 1;
233*f3782652STreehugger Robot svar16_b = 1;
234*f3782652STreehugger Robot Overflow = init_Overflow;
235*f3782652STreehugger Robot Carry = init_Carry;
236*f3782652STreehugger Robot svar16_c = add(svar16_a, svar16_b);
237*f3782652STreehugger Robot fprintf(ref_file, "add(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
238*f3782652STreehugger Robot
239*f3782652STreehugger Robot svar16_a = -1;
240*f3782652STreehugger Robot svar16_b = -1;
241*f3782652STreehugger Robot Overflow = init_Overflow;
242*f3782652STreehugger Robot Carry = init_Carry;
243*f3782652STreehugger Robot svar16_c = add(svar16_a, svar16_b);
244*f3782652STreehugger Robot fprintf(ref_file, "add(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
245*f3782652STreehugger Robot
246*f3782652STreehugger Robot svar16_a = 20000;
247*f3782652STreehugger Robot svar16_b = 20000;
248*f3782652STreehugger Robot Overflow = init_Overflow;
249*f3782652STreehugger Robot Carry = init_Carry;
250*f3782652STreehugger Robot svar16_c = add(svar16_a, svar16_b);
251*f3782652STreehugger Robot fprintf(ref_file, "add(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
252*f3782652STreehugger Robot
253*f3782652STreehugger Robot svar16_a = -20000;
254*f3782652STreehugger Robot svar16_b = -20000;
255*f3782652STreehugger Robot Overflow = init_Overflow;
256*f3782652STreehugger Robot Carry = init_Carry;
257*f3782652STreehugger Robot svar16_c = add(svar16_a, svar16_b);
258*f3782652STreehugger Robot fprintf(ref_file, "add(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
259*f3782652STreehugger Robot
260*f3782652STreehugger Robot
261*f3782652STreehugger Robot /* sub */
262*f3782652STreehugger Robot /* int16_t sub(int16_t x, int16_t y) */
263*f3782652STreehugger Robot svar16_a = 1;
264*f3782652STreehugger Robot svar16_b = 1;
265*f3782652STreehugger Robot Overflow = init_Overflow;
266*f3782652STreehugger Robot Carry = init_Carry;
267*f3782652STreehugger Robot svar16_c = sub(svar16_a, svar16_b);
268*f3782652STreehugger Robot fprintf(ref_file, "sub(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
269*f3782652STreehugger Robot
270*f3782652STreehugger Robot svar16_a = -1;
271*f3782652STreehugger Robot svar16_b = -1;
272*f3782652STreehugger Robot Overflow = init_Overflow;
273*f3782652STreehugger Robot Carry = init_Carry;
274*f3782652STreehugger Robot svar16_c = sub(svar16_a, svar16_b);
275*f3782652STreehugger Robot fprintf(ref_file, "sub(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
276*f3782652STreehugger Robot
277*f3782652STreehugger Robot svar16_a = 20000;
278*f3782652STreehugger Robot svar16_b = 20000;
279*f3782652STreehugger Robot Overflow = init_Overflow;
280*f3782652STreehugger Robot Carry = init_Carry;
281*f3782652STreehugger Robot svar16_c = sub(svar16_a, svar16_b);
282*f3782652STreehugger Robot fprintf(ref_file, "sub(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
283*f3782652STreehugger Robot
284*f3782652STreehugger Robot svar16_a = -20000;
285*f3782652STreehugger Robot svar16_b = -20000;
286*f3782652STreehugger Robot Overflow = init_Overflow;
287*f3782652STreehugger Robot Carry = init_Carry;
288*f3782652STreehugger Robot svar16_c = sub(svar16_a, svar16_b);
289*f3782652STreehugger Robot fprintf(ref_file, "sub(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
290*f3782652STreehugger Robot
291*f3782652STreehugger Robot svar16_a = 0;
292*f3782652STreehugger Robot svar16_b = -32768;
293*f3782652STreehugger Robot Overflow = init_Overflow;
294*f3782652STreehugger Robot Carry = init_Carry;
295*f3782652STreehugger Robot svar16_c = sub(svar16_a, svar16_b);
296*f3782652STreehugger Robot fprintf(ref_file, "sub(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
297*f3782652STreehugger Robot
298*f3782652STreehugger Robot
299*f3782652STreehugger Robot /* abs_s */
300*f3782652STreehugger Robot /* int16_t abs_s(int16_t x) */
301*f3782652STreehugger Robot svar16_b = 1;
302*f3782652STreehugger Robot Overflow = init_Overflow;
303*f3782652STreehugger Robot Carry = init_Carry;
304*f3782652STreehugger Robot svar16_a = abs_s(svar16_b);
305*f3782652STreehugger Robot fprintf(ref_file, "abs_s(%#x) = %#x overflow %d carry %d\n", svar16_b, svar16_a, Overflow, Carry);
306*f3782652STreehugger Robot
307*f3782652STreehugger Robot svar16_b = -1;
308*f3782652STreehugger Robot Overflow = init_Overflow;
309*f3782652STreehugger Robot Carry = init_Carry;
310*f3782652STreehugger Robot svar16_a = abs_s(svar16_b);
311*f3782652STreehugger Robot fprintf(ref_file, "abs_s(%#x) = %#x overflow %d carry %d\n", svar16_b, svar16_a, Overflow, Carry);
312*f3782652STreehugger Robot
313*f3782652STreehugger Robot svar16_b = -32768;
314*f3782652STreehugger Robot Overflow = init_Overflow;
315*f3782652STreehugger Robot Carry = init_Carry;
316*f3782652STreehugger Robot svar16_a = abs_s(svar16_b);
317*f3782652STreehugger Robot fprintf(ref_file, "abs_s(%#x) = %#x overflow %d carry %d\n", svar16_b, svar16_a, Overflow, Carry);
318*f3782652STreehugger Robot
319*f3782652STreehugger Robot
320*f3782652STreehugger Robot /* shl */
321*f3782652STreehugger Robot /* int16_t shl(int16_t x, int16_t y) */
322*f3782652STreehugger Robot svar16_a = 1;
323*f3782652STreehugger Robot svar16_b = 1;
324*f3782652STreehugger Robot Overflow = init_Overflow;
325*f3782652STreehugger Robot Carry = init_Carry;
326*f3782652STreehugger Robot svar16_c = shl(svar16_a, svar16_b);
327*f3782652STreehugger Robot fprintf(ref_file, "shl(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
328*f3782652STreehugger Robot
329*f3782652STreehugger Robot svar16_a = 10;
330*f3782652STreehugger Robot svar16_b = 1;
331*f3782652STreehugger Robot Overflow = init_Overflow;
332*f3782652STreehugger Robot Carry = init_Carry;
333*f3782652STreehugger Robot svar16_c = shl(svar16_a, svar16_b);
334*f3782652STreehugger Robot fprintf(ref_file, "shl(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
335*f3782652STreehugger Robot
336*f3782652STreehugger Robot svar16_a = 0xFFF;
337*f3782652STreehugger Robot svar16_b = 10;
338*f3782652STreehugger Robot Overflow = init_Overflow;
339*f3782652STreehugger Robot Carry = init_Carry;
340*f3782652STreehugger Robot svar16_c = shl(svar16_a, svar16_b);
341*f3782652STreehugger Robot fprintf(ref_file, "shl(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
342*f3782652STreehugger Robot
343*f3782652STreehugger Robot svar16_a = 0xFFF;
344*f3782652STreehugger Robot svar16_b = 20;
345*f3782652STreehugger Robot Overflow = init_Overflow;
346*f3782652STreehugger Robot Carry = init_Carry;
347*f3782652STreehugger Robot svar16_c = shl(svar16_a, svar16_b);
348*f3782652STreehugger Robot fprintf(ref_file, "shl(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
349*f3782652STreehugger Robot
350*f3782652STreehugger Robot svar16_a = 1;
351*f3782652STreehugger Robot svar16_b = -1;
352*f3782652STreehugger Robot Overflow = init_Overflow;
353*f3782652STreehugger Robot Carry = init_Carry;
354*f3782652STreehugger Robot svar16_c = shl(svar16_a, svar16_b);
355*f3782652STreehugger Robot fprintf(ref_file, "shl(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
356*f3782652STreehugger Robot
357*f3782652STreehugger Robot svar16_a = 20;
358*f3782652STreehugger Robot svar16_b = -1;
359*f3782652STreehugger Robot Overflow = init_Overflow;
360*f3782652STreehugger Robot Carry = init_Carry;
361*f3782652STreehugger Robot svar16_c = shl(svar16_a, svar16_b);
362*f3782652STreehugger Robot fprintf(ref_file, "shl(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
363*f3782652STreehugger Robot
364*f3782652STreehugger Robot svar16_a = 0xFFF;
365*f3782652STreehugger Robot svar16_b = -10;
366*f3782652STreehugger Robot Overflow = init_Overflow;
367*f3782652STreehugger Robot Carry = init_Carry;
368*f3782652STreehugger Robot svar16_c = shl(svar16_a, svar16_b);
369*f3782652STreehugger Robot fprintf(ref_file, "shl(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
370*f3782652STreehugger Robot
371*f3782652STreehugger Robot svar16_a = 0xFFF;
372*f3782652STreehugger Robot svar16_b = -64;
373*f3782652STreehugger Robot Overflow = init_Overflow;
374*f3782652STreehugger Robot Carry = init_Carry;
375*f3782652STreehugger Robot svar16_c = shl(svar16_a, svar16_b);
376*f3782652STreehugger Robot fprintf(ref_file, "shl(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
377*f3782652STreehugger Robot
378*f3782652STreehugger Robot
379*f3782652STreehugger Robot /* shr */
380*f3782652STreehugger Robot /* int16_t shr(int16_t x, int16_t y) */
381*f3782652STreehugger Robot svar16_a = 1;
382*f3782652STreehugger Robot svar16_b = -1;
383*f3782652STreehugger Robot Overflow = init_Overflow;
384*f3782652STreehugger Robot Carry = init_Carry;
385*f3782652STreehugger Robot svar16_c = shr(svar16_a, svar16_b);
386*f3782652STreehugger Robot fprintf(ref_file, "shr(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
387*f3782652STreehugger Robot
388*f3782652STreehugger Robot svar16_a = 10;
389*f3782652STreehugger Robot svar16_b = -1;
390*f3782652STreehugger Robot Overflow = init_Overflow;
391*f3782652STreehugger Robot Carry = init_Carry;
392*f3782652STreehugger Robot svar16_c = shr(svar16_a, svar16_b);
393*f3782652STreehugger Robot fprintf(ref_file, "shr(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
394*f3782652STreehugger Robot
395*f3782652STreehugger Robot svar16_a = 0xFFF;
396*f3782652STreehugger Robot svar16_b = -10;
397*f3782652STreehugger Robot Overflow = init_Overflow;
398*f3782652STreehugger Robot Carry = init_Carry;
399*f3782652STreehugger Robot svar16_c = shr(svar16_a, svar16_b);
400*f3782652STreehugger Robot fprintf(ref_file, "shr(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
401*f3782652STreehugger Robot
402*f3782652STreehugger Robot svar16_a = 0xFFF;
403*f3782652STreehugger Robot svar16_b = -20;
404*f3782652STreehugger Robot Overflow = init_Overflow;
405*f3782652STreehugger Robot Carry = init_Carry;
406*f3782652STreehugger Robot svar16_c = shr(svar16_a, svar16_b);
407*f3782652STreehugger Robot fprintf(ref_file, "shr(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
408*f3782652STreehugger Robot
409*f3782652STreehugger Robot svar16_a = 1;
410*f3782652STreehugger Robot svar16_b = 1;
411*f3782652STreehugger Robot Overflow = init_Overflow;
412*f3782652STreehugger Robot Carry = init_Carry;
413*f3782652STreehugger Robot svar16_c = shr(svar16_a, svar16_b);
414*f3782652STreehugger Robot fprintf(ref_file, "shr(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
415*f3782652STreehugger Robot
416*f3782652STreehugger Robot svar16_a = 20;
417*f3782652STreehugger Robot svar16_b = 1;
418*f3782652STreehugger Robot Overflow = init_Overflow;
419*f3782652STreehugger Robot Carry = init_Carry;
420*f3782652STreehugger Robot svar16_c = shr(svar16_a, svar16_b);
421*f3782652STreehugger Robot fprintf(ref_file, "shr(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
422*f3782652STreehugger Robot
423*f3782652STreehugger Robot svar16_a = 0xFFF;
424*f3782652STreehugger Robot svar16_b = 10;
425*f3782652STreehugger Robot Overflow = init_Overflow;
426*f3782652STreehugger Robot Carry = init_Carry;
427*f3782652STreehugger Robot svar16_c = shr(svar16_a, svar16_b);
428*f3782652STreehugger Robot fprintf(ref_file, "shr(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
429*f3782652STreehugger Robot
430*f3782652STreehugger Robot svar16_a = 0xFFF;
431*f3782652STreehugger Robot svar16_b = 64;
432*f3782652STreehugger Robot Overflow = init_Overflow;
433*f3782652STreehugger Robot Carry = init_Carry;
434*f3782652STreehugger Robot svar16_c = shr(svar16_a, svar16_b);
435*f3782652STreehugger Robot fprintf(ref_file, "shr(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
436*f3782652STreehugger Robot
437*f3782652STreehugger Robot
438*f3782652STreehugger Robot /* mult */
439*f3782652STreehugger Robot /* int16_t mult(int16_t x, int16_t y) */
440*f3782652STreehugger Robot svar16_a = 2;
441*f3782652STreehugger Robot svar16_b = 2;
442*f3782652STreehugger Robot Overflow = init_Overflow;
443*f3782652STreehugger Robot Carry = init_Carry;
444*f3782652STreehugger Robot svar16_c = mult(svar16_a, svar16_b);
445*f3782652STreehugger Robot fprintf(ref_file, "mult(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
446*f3782652STreehugger Robot
447*f3782652STreehugger Robot svar16_a = -1;
448*f3782652STreehugger Robot svar16_b = -1;
449*f3782652STreehugger Robot Overflow = init_Overflow;
450*f3782652STreehugger Robot Carry = init_Carry;
451*f3782652STreehugger Robot svar16_c = mult(svar16_a, svar16_b);
452*f3782652STreehugger Robot fprintf(ref_file, "mult(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
453*f3782652STreehugger Robot
454*f3782652STreehugger Robot svar16_a = 0x8000;
455*f3782652STreehugger Robot svar16_b = 0x8000;
456*f3782652STreehugger Robot Overflow = init_Overflow;
457*f3782652STreehugger Robot Carry = init_Carry;
458*f3782652STreehugger Robot svar16_c = mult(svar16_a, svar16_b);
459*f3782652STreehugger Robot fprintf(ref_file, "mult(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
460*f3782652STreehugger Robot
461*f3782652STreehugger Robot
462*f3782652STreehugger Robot /* L_mult */
463*f3782652STreehugger Robot /* int32_t L_mult(int16_t x, int16_t y) */
464*f3782652STreehugger Robot svar16_a = 2;
465*f3782652STreehugger Robot svar16_b = 2;
466*f3782652STreehugger Robot Overflow = init_Overflow;
467*f3782652STreehugger Robot Carry = init_Carry;
468*f3782652STreehugger Robot svar32_a = L_mult(svar16_a, svar16_b);
469*f3782652STreehugger Robot fprintf(ref_file, "L_mult(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar32_a, Overflow, Carry);
470*f3782652STreehugger Robot
471*f3782652STreehugger Robot svar16_a = -1;
472*f3782652STreehugger Robot svar16_b = -1;
473*f3782652STreehugger Robot Overflow = init_Overflow;
474*f3782652STreehugger Robot Carry = init_Carry;
475*f3782652STreehugger Robot svar32_a = L_mult(svar16_a, svar16_b);
476*f3782652STreehugger Robot fprintf(ref_file, "L_mult(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar32_a, Overflow, Carry);
477*f3782652STreehugger Robot
478*f3782652STreehugger Robot svar16_a = 0x8000;
479*f3782652STreehugger Robot svar16_b = 0x8000;
480*f3782652STreehugger Robot Overflow = init_Overflow;
481*f3782652STreehugger Robot Carry = init_Carry;
482*f3782652STreehugger Robot svar32_a = L_mult(svar16_a, svar16_b);
483*f3782652STreehugger Robot fprintf(ref_file, "L_mult(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar32_a, Overflow, Carry);
484*f3782652STreehugger Robot
485*f3782652STreehugger Robot
486*f3782652STreehugger Robot /* negate */
487*f3782652STreehugger Robot /* int16_t negate(int16_t x) */
488*f3782652STreehugger Robot svar16_b = 1;
489*f3782652STreehugger Robot Overflow = init_Overflow;
490*f3782652STreehugger Robot Carry = init_Carry;
491*f3782652STreehugger Robot svar16_a = negate(svar16_b);
492*f3782652STreehugger Robot fprintf(ref_file, "negate(%#x) = %#x overflow %d carry %d\n", svar16_b, svar16_a, Overflow, Carry);
493*f3782652STreehugger Robot
494*f3782652STreehugger Robot svar16_b = -1;
495*f3782652STreehugger Robot Overflow = init_Overflow;
496*f3782652STreehugger Robot Carry = init_Carry;
497*f3782652STreehugger Robot svar16_a = negate(svar16_b);
498*f3782652STreehugger Robot fprintf(ref_file, "negate(%#x) = %#x overflow %d carry %d\n", svar16_b, svar16_a, Overflow, Carry);
499*f3782652STreehugger Robot
500*f3782652STreehugger Robot svar16_b = -32768;
501*f3782652STreehugger Robot Overflow = init_Overflow;
502*f3782652STreehugger Robot Carry = init_Carry;
503*f3782652STreehugger Robot svar16_a = negate(svar16_b);
504*f3782652STreehugger Robot fprintf(ref_file, "negate(%#x) = %#x overflow %d carry %d\n", svar16_b, svar16_a, Overflow, Carry);
505*f3782652STreehugger Robot
506*f3782652STreehugger Robot
507*f3782652STreehugger Robot /* extract_h */
508*f3782652STreehugger Robot /* int16_t extract_h(int32_t x) */
509*f3782652STreehugger Robot svar32_a = 1;
510*f3782652STreehugger Robot Overflow = init_Overflow;
511*f3782652STreehugger Robot Carry = init_Carry;
512*f3782652STreehugger Robot svar16_a = extract_h(svar32_a);
513*f3782652STreehugger Robot fprintf(ref_file, "extract_h(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
514*f3782652STreehugger Robot
515*f3782652STreehugger Robot svar32_a = -1;
516*f3782652STreehugger Robot Overflow = init_Overflow;
517*f3782652STreehugger Robot Carry = init_Carry;
518*f3782652STreehugger Robot svar16_a = extract_h(svar32_a);
519*f3782652STreehugger Robot fprintf(ref_file, "extract_h(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
520*f3782652STreehugger Robot
521*f3782652STreehugger Robot svar32_a = -32768;
522*f3782652STreehugger Robot Overflow = init_Overflow;
523*f3782652STreehugger Robot Carry = init_Carry;
524*f3782652STreehugger Robot svar16_a = extract_h(svar32_a);
525*f3782652STreehugger Robot fprintf(ref_file, "extract_h(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
526*f3782652STreehugger Robot
527*f3782652STreehugger Robot svar32_a = 0x12345678;
528*f3782652STreehugger Robot Overflow = init_Overflow;
529*f3782652STreehugger Robot Carry = init_Carry;
530*f3782652STreehugger Robot svar16_a = extract_h(svar32_a);
531*f3782652STreehugger Robot fprintf(ref_file, "extract_h(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
532*f3782652STreehugger Robot
533*f3782652STreehugger Robot
534*f3782652STreehugger Robot /* extract_l */
535*f3782652STreehugger Robot /* int16_t extract_l(int32_t x) */
536*f3782652STreehugger Robot svar32_a = 1;
537*f3782652STreehugger Robot Overflow = init_Overflow;
538*f3782652STreehugger Robot Carry = init_Carry;
539*f3782652STreehugger Robot svar16_a = extract_l(svar32_a);
540*f3782652STreehugger Robot fprintf(ref_file, "extract_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
541*f3782652STreehugger Robot
542*f3782652STreehugger Robot svar32_a = -1;
543*f3782652STreehugger Robot Overflow = init_Overflow;
544*f3782652STreehugger Robot Carry = init_Carry;
545*f3782652STreehugger Robot svar16_a = extract_l(svar32_a);
546*f3782652STreehugger Robot fprintf(ref_file, "extract_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
547*f3782652STreehugger Robot
548*f3782652STreehugger Robot svar32_a = -32768;
549*f3782652STreehugger Robot Overflow = init_Overflow;
550*f3782652STreehugger Robot Carry = init_Carry;
551*f3782652STreehugger Robot svar16_a = extract_l(svar32_a);
552*f3782652STreehugger Robot fprintf(ref_file, "extract_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
553*f3782652STreehugger Robot
554*f3782652STreehugger Robot svar32_a = 0x43218765;
555*f3782652STreehugger Robot Overflow = init_Overflow;
556*f3782652STreehugger Robot Carry = init_Carry;
557*f3782652STreehugger Robot svar16_a = extract_l(svar32_a);
558*f3782652STreehugger Robot fprintf(ref_file, "extract_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
559*f3782652STreehugger Robot
560*f3782652STreehugger Robot
561*f3782652STreehugger Robot /* round */
562*f3782652STreehugger Robot /* int16_t round(int32_t x) */
563*f3782652STreehugger Robot svar32_a = 1;
564*f3782652STreehugger Robot Overflow = init_Overflow;
565*f3782652STreehugger Robot Carry = init_Carry;
566*f3782652STreehugger Robot svar16_a = round(svar32_a);
567*f3782652STreehugger Robot fprintf(ref_file, "round(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
568*f3782652STreehugger Robot
569*f3782652STreehugger Robot svar32_a = -1;
570*f3782652STreehugger Robot Overflow = init_Overflow;
571*f3782652STreehugger Robot Carry = init_Carry;
572*f3782652STreehugger Robot svar16_a = round(svar32_a);
573*f3782652STreehugger Robot fprintf(ref_file, "round(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
574*f3782652STreehugger Robot
575*f3782652STreehugger Robot svar32_a = -32768;
576*f3782652STreehugger Robot Overflow = init_Overflow;
577*f3782652STreehugger Robot Carry = init_Carry;
578*f3782652STreehugger Robot svar16_a = round(svar32_a);
579*f3782652STreehugger Robot fprintf(ref_file, "round(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
580*f3782652STreehugger Robot
581*f3782652STreehugger Robot svar32_a = 0x43218765;
582*f3782652STreehugger Robot Overflow = init_Overflow;
583*f3782652STreehugger Robot Carry = init_Carry;
584*f3782652STreehugger Robot svar16_a = round(svar32_a);
585*f3782652STreehugger Robot fprintf(ref_file, "round(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
586*f3782652STreehugger Robot
587*f3782652STreehugger Robot svar32_a = 0x87654321;
588*f3782652STreehugger Robot Overflow = init_Overflow;
589*f3782652STreehugger Robot Carry = init_Carry;
590*f3782652STreehugger Robot svar16_a = round(svar32_a);
591*f3782652STreehugger Robot fprintf(ref_file, "round(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
592*f3782652STreehugger Robot
593*f3782652STreehugger Robot
594*f3782652STreehugger Robot /* L_mac */
595*f3782652STreehugger Robot /* int32_t L_mac(int32_t acc, int16_t x, int16_t y) */
596*f3782652STreehugger Robot svar16_a = 2;
597*f3782652STreehugger Robot svar16_b = 2;
598*f3782652STreehugger Robot svar32_a = 0x1234;
599*f3782652STreehugger Robot Overflow = init_Overflow;
600*f3782652STreehugger Robot Carry = init_Carry;
601*f3782652STreehugger Robot svar32_b = L_mac(svar32_a, svar16_a, svar16_b);
602*f3782652STreehugger Robot fprintf(ref_file, "L_mac(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
603*f3782652STreehugger Robot
604*f3782652STreehugger Robot svar16_a = -1;
605*f3782652STreehugger Robot svar16_b = -1;
606*f3782652STreehugger Robot Overflow = init_Overflow;
607*f3782652STreehugger Robot Carry = init_Carry;
608*f3782652STreehugger Robot svar32_b = L_mac(svar32_a, svar16_a, svar16_b);
609*f3782652STreehugger Robot fprintf(ref_file, "L_mac(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
610*f3782652STreehugger Robot
611*f3782652STreehugger Robot svar16_a = 0x8000;
612*f3782652STreehugger Robot svar16_b = 0x8000;
613*f3782652STreehugger Robot Overflow = init_Overflow;
614*f3782652STreehugger Robot Carry = init_Carry;
615*f3782652STreehugger Robot svar32_b = L_mac(svar32_a, svar16_a, svar16_b);
616*f3782652STreehugger Robot fprintf(ref_file, "L_mac(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
617*f3782652STreehugger Robot
618*f3782652STreehugger Robot svar16_a = 0x8000;
619*f3782652STreehugger Robot svar16_b = 0x8000;
620*f3782652STreehugger Robot Overflow = init_Overflow;
621*f3782652STreehugger Robot Carry = init_Carry;
622*f3782652STreehugger Robot svar32_a = -1;
623*f3782652STreehugger Robot svar32_b = L_mac(svar32_a, svar16_a, svar16_b);
624*f3782652STreehugger Robot fprintf(ref_file, "L_mac(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
625*f3782652STreehugger Robot
626*f3782652STreehugger Robot
627*f3782652STreehugger Robot /* L_msu */
628*f3782652STreehugger Robot /* int32_t L_msu(int32_t acc, int16_t x, int16_t y) */
629*f3782652STreehugger Robot svar16_a = 2;
630*f3782652STreehugger Robot svar16_b = 2;
631*f3782652STreehugger Robot svar32_a = 0x1234;
632*f3782652STreehugger Robot Overflow = init_Overflow;
633*f3782652STreehugger Robot Carry = init_Carry;
634*f3782652STreehugger Robot svar32_b = L_msu(svar32_a, svar16_a, svar16_b);
635*f3782652STreehugger Robot fprintf(ref_file, "L_msu(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
636*f3782652STreehugger Robot
637*f3782652STreehugger Robot svar16_a = -1;
638*f3782652STreehugger Robot svar16_b = -1;
639*f3782652STreehugger Robot Overflow = init_Overflow;
640*f3782652STreehugger Robot Carry = init_Carry;
641*f3782652STreehugger Robot svar32_b = L_msu(svar32_a, svar16_a, svar16_b);
642*f3782652STreehugger Robot fprintf(ref_file, "L_msu(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
643*f3782652STreehugger Robot
644*f3782652STreehugger Robot svar16_a = 0x8000;
645*f3782652STreehugger Robot svar16_b = 0x8000;
646*f3782652STreehugger Robot Overflow = init_Overflow;
647*f3782652STreehugger Robot Carry = init_Carry;
648*f3782652STreehugger Robot svar32_b = L_msu(svar32_a, svar16_a, svar16_b);
649*f3782652STreehugger Robot fprintf(ref_file, "L_msu(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
650*f3782652STreehugger Robot
651*f3782652STreehugger Robot svar16_a = 0x8000;
652*f3782652STreehugger Robot svar16_b = 0x8000;
653*f3782652STreehugger Robot svar32_a = 1;
654*f3782652STreehugger Robot Overflow = init_Overflow;
655*f3782652STreehugger Robot Carry = init_Carry;
656*f3782652STreehugger Robot svar32_b = L_msu(svar32_a, svar16_a, svar16_b);
657*f3782652STreehugger Robot fprintf(ref_file, "L_msu(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar32_b, Overflow, Carry);
658*f3782652STreehugger Robot
659*f3782652STreehugger Robot
660*f3782652STreehugger Robot /* L_add */
661*f3782652STreehugger Robot /* int32_t L_add(int32_t val1, int32_t val2); */
662*f3782652STreehugger Robot svar32_a = 1;
663*f3782652STreehugger Robot svar32_b = 2;
664*f3782652STreehugger Robot Overflow = init_Overflow;
665*f3782652STreehugger Robot Carry = init_Carry;
666*f3782652STreehugger Robot svar32_c = L_add(svar32_a, svar32_b);
667*f3782652STreehugger Robot fprintf(ref_file, "L_add(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
668*f3782652STreehugger Robot
669*f3782652STreehugger Robot svar32_a = -1;
670*f3782652STreehugger Robot svar32_b = -2;
671*f3782652STreehugger Robot Overflow = init_Overflow;
672*f3782652STreehugger Robot Carry = init_Carry;
673*f3782652STreehugger Robot svar32_c = L_add(svar32_a, svar32_b);
674*f3782652STreehugger Robot fprintf(ref_file, "L_add(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
675*f3782652STreehugger Robot
676*f3782652STreehugger Robot svar32_a = -1;
677*f3782652STreehugger Robot svar32_b = 2;
678*f3782652STreehugger Robot Overflow = init_Overflow;
679*f3782652STreehugger Robot Carry = init_Carry;
680*f3782652STreehugger Robot svar32_c = L_add(svar32_a, svar32_b);
681*f3782652STreehugger Robot fprintf(ref_file, "L_add(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
682*f3782652STreehugger Robot
683*f3782652STreehugger Robot svar32_a = 0x7000;
684*f3782652STreehugger Robot svar32_b = 0x7000;
685*f3782652STreehugger Robot Overflow = init_Overflow;
686*f3782652STreehugger Robot Carry = init_Carry;
687*f3782652STreehugger Robot svar32_c = L_add(svar32_a, svar32_b);
688*f3782652STreehugger Robot fprintf(ref_file, "L_add(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
689*f3782652STreehugger Robot
690*f3782652STreehugger Robot svar32_a = 0x8FFF;
691*f3782652STreehugger Robot svar32_b = 0x8FFF;
692*f3782652STreehugger Robot Overflow = init_Overflow;
693*f3782652STreehugger Robot Carry = init_Carry;
694*f3782652STreehugger Robot svar32_c = L_add(svar32_a, svar32_b);
695*f3782652STreehugger Robot fprintf(ref_file, "L_add(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
696*f3782652STreehugger Robot
697*f3782652STreehugger Robot svar32_a = 0x70000000;
698*f3782652STreehugger Robot svar32_b = 0x70000000;
699*f3782652STreehugger Robot Overflow = init_Overflow;
700*f3782652STreehugger Robot Carry = init_Carry;
701*f3782652STreehugger Robot svar32_c = L_add(svar32_a, svar32_b);
702*f3782652STreehugger Robot fprintf(ref_file, "L_add(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
703*f3782652STreehugger Robot
704*f3782652STreehugger Robot svar32_a = 0x8FFFFFFF;
705*f3782652STreehugger Robot svar32_b = 0x8FFFFFFF;
706*f3782652STreehugger Robot Overflow = init_Overflow;
707*f3782652STreehugger Robot Carry = init_Carry;
708*f3782652STreehugger Robot svar32_c = L_add(svar32_a, svar32_b);
709*f3782652STreehugger Robot fprintf(ref_file, "L_add(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
710*f3782652STreehugger Robot
711*f3782652STreehugger Robot /* L_sub */
712*f3782652STreehugger Robot /* int32_t L_sub(int32_t val1, int32_t val2); */
713*f3782652STreehugger Robot svar32_a = 1;
714*f3782652STreehugger Robot svar32_b = 2;
715*f3782652STreehugger Robot Overflow = init_Overflow;
716*f3782652STreehugger Robot Carry = init_Carry;
717*f3782652STreehugger Robot svar32_c = L_sub(svar32_a, svar32_b);
718*f3782652STreehugger Robot fprintf(ref_file, "L_sub(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
719*f3782652STreehugger Robot
720*f3782652STreehugger Robot svar32_a = -1;
721*f3782652STreehugger Robot svar32_b = -2;
722*f3782652STreehugger Robot Overflow = init_Overflow;
723*f3782652STreehugger Robot Carry = init_Carry;
724*f3782652STreehugger Robot svar32_c = L_sub(svar32_a, svar32_b);
725*f3782652STreehugger Robot fprintf(ref_file, "L_sub(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
726*f3782652STreehugger Robot
727*f3782652STreehugger Robot svar32_a = -1;
728*f3782652STreehugger Robot svar32_b = 2;
729*f3782652STreehugger Robot Overflow = init_Overflow;
730*f3782652STreehugger Robot Carry = init_Carry;
731*f3782652STreehugger Robot svar32_c = L_sub(svar32_a, svar32_b);
732*f3782652STreehugger Robot fprintf(ref_file, "L_sub(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
733*f3782652STreehugger Robot
734*f3782652STreehugger Robot svar32_a = 0x7000;
735*f3782652STreehugger Robot svar32_b = 0xFFFF9000;
736*f3782652STreehugger Robot Overflow = init_Overflow;
737*f3782652STreehugger Robot Carry = init_Carry;
738*f3782652STreehugger Robot svar32_c = L_sub(svar32_a, svar32_b);
739*f3782652STreehugger Robot fprintf(ref_file, "L_sub(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
740*f3782652STreehugger Robot
741*f3782652STreehugger Robot svar32_a = 0x8FFF;
742*f3782652STreehugger Robot svar32_b = 0xFFFF7001;
743*f3782652STreehugger Robot Overflow = init_Overflow;
744*f3782652STreehugger Robot Carry = init_Carry;
745*f3782652STreehugger Robot svar32_c = L_sub(svar32_a, svar32_b);
746*f3782652STreehugger Robot fprintf(ref_file, "L_sub(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
747*f3782652STreehugger Robot
748*f3782652STreehugger Robot svar32_a = 0x70000000;
749*f3782652STreehugger Robot svar32_b = 0x90000000;
750*f3782652STreehugger Robot Overflow = init_Overflow;
751*f3782652STreehugger Robot Carry = init_Carry;
752*f3782652STreehugger Robot svar32_c = L_sub(svar32_a, svar32_b);
753*f3782652STreehugger Robot fprintf(ref_file, "L_sub(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
754*f3782652STreehugger Robot
755*f3782652STreehugger Robot svar32_a = 0x8FFFFFFF;
756*f3782652STreehugger Robot svar32_b = 0x70000001;
757*f3782652STreehugger Robot Overflow = init_Overflow;
758*f3782652STreehugger Robot Carry = init_Carry;
759*f3782652STreehugger Robot svar32_c = L_sub(svar32_a, svar32_b);
760*f3782652STreehugger Robot fprintf(ref_file, "L_sub(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
761*f3782652STreehugger Robot
762*f3782652STreehugger Robot svar32_a = 0;
763*f3782652STreehugger Robot svar32_b = 0x80000000;
764*f3782652STreehugger Robot Overflow = init_Overflow;
765*f3782652STreehugger Robot Carry = init_Carry;
766*f3782652STreehugger Robot svar32_c = L_sub(svar32_a, svar32_b);
767*f3782652STreehugger Robot fprintf(ref_file, "L_sub(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
768*f3782652STreehugger Robot
769*f3782652STreehugger Robot
770*f3782652STreehugger Robot /* L_add_c */
771*f3782652STreehugger Robot /* int32_t L_add_c(int32_t val1, int32_t val2); */
772*f3782652STreehugger Robot test_32_fn_32_32(FN(L_add_c), init_Overflow, init_Carry);
773*f3782652STreehugger Robot
774*f3782652STreehugger Robot
775*f3782652STreehugger Robot
776*f3782652STreehugger Robot /* L_sub_c */
777*f3782652STreehugger Robot /* int32_t L_sub_c(int32_t val1, int32_t val2); */
778*f3782652STreehugger Robot #undef MYFN
779*f3782652STreehugger Robot #define MYFN L_sub_c
780*f3782652STreehugger Robot svar32_a = 1;
781*f3782652STreehugger Robot svar32_b = 2;
782*f3782652STreehugger Robot Overflow = init_Overflow;
783*f3782652STreehugger Robot Carry = init_Carry;
784*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
785*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
786*f3782652STreehugger Robot
787*f3782652STreehugger Robot svar32_a = -1;
788*f3782652STreehugger Robot svar32_b = -2;
789*f3782652STreehugger Robot Overflow = init_Overflow;
790*f3782652STreehugger Robot Carry = init_Carry;
791*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
792*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
793*f3782652STreehugger Robot
794*f3782652STreehugger Robot svar32_a = -1;
795*f3782652STreehugger Robot svar32_b = 2;
796*f3782652STreehugger Robot Overflow = init_Overflow;
797*f3782652STreehugger Robot Carry = init_Carry;
798*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
799*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
800*f3782652STreehugger Robot
801*f3782652STreehugger Robot svar32_a = 0x7000;
802*f3782652STreehugger Robot svar32_b = 0x7000;
803*f3782652STreehugger Robot Overflow = init_Overflow;
804*f3782652STreehugger Robot Carry = init_Carry;
805*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
806*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
807*f3782652STreehugger Robot
808*f3782652STreehugger Robot svar32_a = 0x8FFF;
809*f3782652STreehugger Robot svar32_b = 0x8FFF;
810*f3782652STreehugger Robot Overflow = init_Overflow;
811*f3782652STreehugger Robot Carry = init_Carry;
812*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
813*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
814*f3782652STreehugger Robot
815*f3782652STreehugger Robot svar32_a = 0x70000000;
816*f3782652STreehugger Robot svar32_b = 0x70000000;
817*f3782652STreehugger Robot Overflow = init_Overflow;
818*f3782652STreehugger Robot Carry = init_Carry;
819*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
820*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
821*f3782652STreehugger Robot
822*f3782652STreehugger Robot svar32_a = 0x8FFFFFFF;
823*f3782652STreehugger Robot svar32_b = 0x8FFFFFFF;
824*f3782652STreehugger Robot Overflow = init_Overflow;
825*f3782652STreehugger Robot Carry = init_Carry;
826*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
827*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
828*f3782652STreehugger Robot
829*f3782652STreehugger Robot svar32_a = 0x1;
830*f3782652STreehugger Robot svar32_b = 0x80000000;
831*f3782652STreehugger Robot Overflow = init_Overflow;
832*f3782652STreehugger Robot Carry = init_Carry;
833*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
834*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
835*f3782652STreehugger Robot
836*f3782652STreehugger Robot svar32_a = 0xFFFFFFFF;
837*f3782652STreehugger Robot svar32_b = 0x7FFFFFFF;
838*f3782652STreehugger Robot Overflow = init_Overflow;
839*f3782652STreehugger Robot Carry = init_Carry;
840*f3782652STreehugger Robot svar32_c = MYFN(svar32_a, svar32_b);
841*f3782652STreehugger Robot fprintf(ref_file, __STR(MYFN) "(%#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar32_b, svar32_c, Overflow, Carry);
842*f3782652STreehugger Robot
843*f3782652STreehugger Robot
844*f3782652STreehugger Robot /* L_macNs */
845*f3782652STreehugger Robot /* int32_t L_macNs(int32_t acc, int16_t x, int16_t y) */
846*f3782652STreehugger Robot test_32_fn_32_16_16(FN(L_macNs), init_Overflow, init_Carry);
847*f3782652STreehugger Robot
848*f3782652STreehugger Robot /* L_msuNs */
849*f3782652STreehugger Robot /* int32_t L_msuNs(int32_t acc, int16_t x, int16_t y) */
850*f3782652STreehugger Robot test_32_fn_32_16_16(FN(L_msuNs), init_Overflow, init_Carry);
851*f3782652STreehugger Robot
852*f3782652STreehugger Robot
853*f3782652STreehugger Robot /* negate */
854*f3782652STreehugger Robot /* int32_t negate(int32_t x) */
855*f3782652STreehugger Robot svar32_b = 1;
856*f3782652STreehugger Robot Overflow = init_Overflow;
857*f3782652STreehugger Robot Carry = init_Carry;
858*f3782652STreehugger Robot svar32_a = negate(svar32_b);
859*f3782652STreehugger Robot fprintf(ref_file, "negate(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
860*f3782652STreehugger Robot
861*f3782652STreehugger Robot svar32_b = -1;
862*f3782652STreehugger Robot Overflow = init_Overflow;
863*f3782652STreehugger Robot Carry = init_Carry;
864*f3782652STreehugger Robot svar32_a = negate(svar32_b);
865*f3782652STreehugger Robot fprintf(ref_file, "negate(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
866*f3782652STreehugger Robot
867*f3782652STreehugger Robot svar32_b = -32768;
868*f3782652STreehugger Robot Overflow = init_Overflow;
869*f3782652STreehugger Robot Carry = init_Carry;
870*f3782652STreehugger Robot svar32_a = negate(svar32_b);
871*f3782652STreehugger Robot fprintf(ref_file, "negate(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
872*f3782652STreehugger Robot
873*f3782652STreehugger Robot
874*f3782652STreehugger Robot /* mult_r */
875*f3782652STreehugger Robot /* int16_t mult_r(int16_t x, int16_t y) */
876*f3782652STreehugger Robot svar16_a = 2;
877*f3782652STreehugger Robot svar16_b = 2;
878*f3782652STreehugger Robot Overflow = init_Overflow;
879*f3782652STreehugger Robot Carry = init_Carry;
880*f3782652STreehugger Robot svar16_c = mult_r(svar16_a, svar16_b);
881*f3782652STreehugger Robot fprintf(ref_file, "mult_r(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
882*f3782652STreehugger Robot
883*f3782652STreehugger Robot svar16_a = -1;
884*f3782652STreehugger Robot svar16_b = -1;
885*f3782652STreehugger Robot Overflow = init_Overflow;
886*f3782652STreehugger Robot Carry = init_Carry;
887*f3782652STreehugger Robot svar16_c = mult_r(svar16_a, svar16_b);
888*f3782652STreehugger Robot fprintf(ref_file, "mult_r(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
889*f3782652STreehugger Robot
890*f3782652STreehugger Robot svar16_a = 0x8000;
891*f3782652STreehugger Robot svar16_b = 0x8000;
892*f3782652STreehugger Robot Overflow = init_Overflow;
893*f3782652STreehugger Robot Carry = init_Carry;
894*f3782652STreehugger Robot svar16_c = mult_r(svar16_a, svar16_b);
895*f3782652STreehugger Robot fprintf(ref_file, "mult_r(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
896*f3782652STreehugger Robot
897*f3782652STreehugger Robot
898*f3782652STreehugger Robot /* norm_s */
899*f3782652STreehugger Robot /* int16_t norm_s(int32_t x) */
900*f3782652STreehugger Robot svar32_a = 1;
901*f3782652STreehugger Robot Overflow = init_Overflow;
902*f3782652STreehugger Robot Carry = init_Carry;
903*f3782652STreehugger Robot svar16_a = norm_s(svar32_a);
904*f3782652STreehugger Robot fprintf(ref_file, "norm_s(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
905*f3782652STreehugger Robot
906*f3782652STreehugger Robot svar32_a = -1;
907*f3782652STreehugger Robot Overflow = init_Overflow;
908*f3782652STreehugger Robot Carry = init_Carry;
909*f3782652STreehugger Robot svar16_a = norm_s(svar32_a);
910*f3782652STreehugger Robot fprintf(ref_file, "norm_s(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
911*f3782652STreehugger Robot
912*f3782652STreehugger Robot svar32_a = -32768;
913*f3782652STreehugger Robot Overflow = init_Overflow;
914*f3782652STreehugger Robot Carry = init_Carry;
915*f3782652STreehugger Robot svar16_a = norm_s(svar32_a);
916*f3782652STreehugger Robot fprintf(ref_file, "norm_s(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
917*f3782652STreehugger Robot
918*f3782652STreehugger Robot svar32_a = 12000;
919*f3782652STreehugger Robot Overflow = init_Overflow;
920*f3782652STreehugger Robot Carry = init_Carry;
921*f3782652STreehugger Robot svar16_a = norm_s(svar32_a);
922*f3782652STreehugger Robot fprintf(ref_file, "norm_s(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
923*f3782652STreehugger Robot
924*f3782652STreehugger Robot
925*f3782652STreehugger Robot /* norm_l */
926*f3782652STreehugger Robot /* int16_t norm_l(int16_t x) */
927*f3782652STreehugger Robot svar32_a = 1;
928*f3782652STreehugger Robot Overflow = init_Overflow;
929*f3782652STreehugger Robot Carry = init_Carry;
930*f3782652STreehugger Robot svar16_a = norm_l(svar32_a);
931*f3782652STreehugger Robot fprintf(ref_file, "norm_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
932*f3782652STreehugger Robot
933*f3782652STreehugger Robot svar32_a = -1;
934*f3782652STreehugger Robot Overflow = init_Overflow;
935*f3782652STreehugger Robot Carry = init_Carry;
936*f3782652STreehugger Robot svar16_a = norm_l(svar32_a);
937*f3782652STreehugger Robot fprintf(ref_file, "norm_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
938*f3782652STreehugger Robot
939*f3782652STreehugger Robot svar32_a = -32768;
940*f3782652STreehugger Robot Overflow = init_Overflow;
941*f3782652STreehugger Robot Carry = init_Carry;
942*f3782652STreehugger Robot svar16_a = norm_l(svar32_a);
943*f3782652STreehugger Robot fprintf(ref_file, "norm_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
944*f3782652STreehugger Robot
945*f3782652STreehugger Robot svar32_a = 12000;
946*f3782652STreehugger Robot Overflow = init_Overflow;
947*f3782652STreehugger Robot Carry = init_Carry;
948*f3782652STreehugger Robot svar16_a = norm_l(svar32_a);
949*f3782652STreehugger Robot fprintf(ref_file, "norm_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
950*f3782652STreehugger Robot
951*f3782652STreehugger Robot svar32_a = 0x123456;
952*f3782652STreehugger Robot Overflow = init_Overflow;
953*f3782652STreehugger Robot Carry = init_Carry;
954*f3782652STreehugger Robot svar16_a = norm_l(svar32_a);
955*f3782652STreehugger Robot fprintf(ref_file, "norm_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
956*f3782652STreehugger Robot
957*f3782652STreehugger Robot svar32_a = 0xABCDEF;
958*f3782652STreehugger Robot Overflow = init_Overflow;
959*f3782652STreehugger Robot Carry = init_Carry;
960*f3782652STreehugger Robot svar16_a = norm_l(svar32_a);
961*f3782652STreehugger Robot fprintf(ref_file, "norm_l(%#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, Overflow, Carry);
962*f3782652STreehugger Robot
963*f3782652STreehugger Robot
964*f3782652STreehugger Robot /* L_shl */
965*f3782652STreehugger Robot /* int32_t L_shl(int32_t x, int16_t y) */
966*f3782652STreehugger Robot svar32_a = 1;
967*f3782652STreehugger Robot svar16_b = 1;
968*f3782652STreehugger Robot Overflow = init_Overflow;
969*f3782652STreehugger Robot Carry = init_Carry;
970*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
971*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
972*f3782652STreehugger Robot
973*f3782652STreehugger Robot svar32_a = 10;
974*f3782652STreehugger Robot svar16_b = 1;
975*f3782652STreehugger Robot Overflow = init_Overflow;
976*f3782652STreehugger Robot Carry = init_Carry;
977*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
978*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
979*f3782652STreehugger Robot
980*f3782652STreehugger Robot svar32_a = 0xFFF;
981*f3782652STreehugger Robot svar16_b = 10;
982*f3782652STreehugger Robot Overflow = init_Overflow;
983*f3782652STreehugger Robot Carry = init_Carry;
984*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
985*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
986*f3782652STreehugger Robot
987*f3782652STreehugger Robot svar32_a = 0xFFF;
988*f3782652STreehugger Robot svar16_b = 20;
989*f3782652STreehugger Robot Overflow = init_Overflow;
990*f3782652STreehugger Robot Carry = init_Carry;
991*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
992*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
993*f3782652STreehugger Robot
994*f3782652STreehugger Robot svar32_a = 0x12345678;
995*f3782652STreehugger Robot svar16_b = 2;
996*f3782652STreehugger Robot Overflow = init_Overflow;
997*f3782652STreehugger Robot Carry = init_Carry;
998*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
999*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1000*f3782652STreehugger Robot
1001*f3782652STreehugger Robot svar32_a = 0x12345678;
1002*f3782652STreehugger Robot svar16_b = 40;
1003*f3782652STreehugger Robot Overflow = init_Overflow;
1004*f3782652STreehugger Robot Carry = init_Carry;
1005*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
1006*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1007*f3782652STreehugger Robot
1008*f3782652STreehugger Robot svar32_a = 1;
1009*f3782652STreehugger Robot svar16_b = -1;
1010*f3782652STreehugger Robot Overflow = init_Overflow;
1011*f3782652STreehugger Robot Carry = init_Carry;
1012*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
1013*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1014*f3782652STreehugger Robot
1015*f3782652STreehugger Robot svar32_a = 20;
1016*f3782652STreehugger Robot svar16_b = -1;
1017*f3782652STreehugger Robot Overflow = init_Overflow;
1018*f3782652STreehugger Robot Carry = init_Carry;
1019*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
1020*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1021*f3782652STreehugger Robot
1022*f3782652STreehugger Robot svar32_a = 0xFFF;
1023*f3782652STreehugger Robot svar16_b = -10;
1024*f3782652STreehugger Robot Overflow = init_Overflow;
1025*f3782652STreehugger Robot Carry = init_Carry;
1026*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
1027*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1028*f3782652STreehugger Robot
1029*f3782652STreehugger Robot svar32_a = 0xFFF;
1030*f3782652STreehugger Robot svar16_b = -64;
1031*f3782652STreehugger Robot Overflow = init_Overflow;
1032*f3782652STreehugger Robot Carry = init_Carry;
1033*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
1034*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1035*f3782652STreehugger Robot
1036*f3782652STreehugger Robot svar32_a = 0x12345678;
1037*f3782652STreehugger Robot svar16_b = -10;
1038*f3782652STreehugger Robot Overflow = init_Overflow;
1039*f3782652STreehugger Robot Carry = init_Carry;
1040*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
1041*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1042*f3782652STreehugger Robot
1043*f3782652STreehugger Robot svar32_a = 0x12345678;
1044*f3782652STreehugger Robot svar16_b = -64;
1045*f3782652STreehugger Robot Overflow = init_Overflow;
1046*f3782652STreehugger Robot Carry = init_Carry;
1047*f3782652STreehugger Robot svar32_c = L_shl(svar32_a, svar16_b);
1048*f3782652STreehugger Robot fprintf(ref_file, "L_shl(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1049*f3782652STreehugger Robot
1050*f3782652STreehugger Robot
1051*f3782652STreehugger Robot /* L_shr */
1052*f3782652STreehugger Robot /* int32_t L_shr(int32_t x, int16_t y) */
1053*f3782652STreehugger Robot svar32_a = 1;
1054*f3782652STreehugger Robot svar16_b = -1;
1055*f3782652STreehugger Robot Overflow = init_Overflow;
1056*f3782652STreehugger Robot Carry = init_Carry;
1057*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1058*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1059*f3782652STreehugger Robot
1060*f3782652STreehugger Robot svar32_a = 10;
1061*f3782652STreehugger Robot svar16_b = -1;
1062*f3782652STreehugger Robot Overflow = init_Overflow;
1063*f3782652STreehugger Robot Carry = init_Carry;
1064*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1065*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1066*f3782652STreehugger Robot
1067*f3782652STreehugger Robot svar32_a = 0xFFF;
1068*f3782652STreehugger Robot svar16_b = -10;
1069*f3782652STreehugger Robot Overflow = init_Overflow;
1070*f3782652STreehugger Robot Carry = init_Carry;
1071*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1072*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1073*f3782652STreehugger Robot
1074*f3782652STreehugger Robot svar32_a = 0xFFF;
1075*f3782652STreehugger Robot svar16_b = -20;
1076*f3782652STreehugger Robot Overflow = init_Overflow;
1077*f3782652STreehugger Robot Carry = init_Carry;
1078*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1079*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1080*f3782652STreehugger Robot
1081*f3782652STreehugger Robot svar32_a = 0x12345678;
1082*f3782652STreehugger Robot svar16_b = -10;
1083*f3782652STreehugger Robot Overflow = init_Overflow;
1084*f3782652STreehugger Robot Carry = init_Carry;
1085*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1086*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1087*f3782652STreehugger Robot
1088*f3782652STreehugger Robot svar32_a = 0x12345678;
1089*f3782652STreehugger Robot svar16_b = -40;
1090*f3782652STreehugger Robot Overflow = init_Overflow;
1091*f3782652STreehugger Robot Carry = init_Carry;
1092*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1093*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1094*f3782652STreehugger Robot
1095*f3782652STreehugger Robot svar32_a = 1;
1096*f3782652STreehugger Robot svar16_b = 1;
1097*f3782652STreehugger Robot Overflow = init_Overflow;
1098*f3782652STreehugger Robot Carry = init_Carry;
1099*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1100*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1101*f3782652STreehugger Robot
1102*f3782652STreehugger Robot svar32_a = 20;
1103*f3782652STreehugger Robot svar16_b = 1;
1104*f3782652STreehugger Robot Overflow = init_Overflow;
1105*f3782652STreehugger Robot Carry = init_Carry;
1106*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1107*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1108*f3782652STreehugger Robot
1109*f3782652STreehugger Robot svar32_a = 0xFFF;
1110*f3782652STreehugger Robot svar16_b = 10;
1111*f3782652STreehugger Robot Overflow = init_Overflow;
1112*f3782652STreehugger Robot Carry = init_Carry;
1113*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1114*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1115*f3782652STreehugger Robot
1116*f3782652STreehugger Robot svar32_a = 0xFFF;
1117*f3782652STreehugger Robot svar16_b = 64;
1118*f3782652STreehugger Robot Overflow = init_Overflow;
1119*f3782652STreehugger Robot Carry = init_Carry;
1120*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1121*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1122*f3782652STreehugger Robot
1123*f3782652STreehugger Robot svar32_a = 0x12345678;
1124*f3782652STreehugger Robot svar16_b = 10;
1125*f3782652STreehugger Robot Overflow = init_Overflow;
1126*f3782652STreehugger Robot Carry = init_Carry;
1127*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1128*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1129*f3782652STreehugger Robot
1130*f3782652STreehugger Robot svar32_a = 0x12345678;
1131*f3782652STreehugger Robot svar16_b = 64;
1132*f3782652STreehugger Robot Overflow = init_Overflow;
1133*f3782652STreehugger Robot Carry = init_Carry;
1134*f3782652STreehugger Robot svar32_c = L_shr(svar32_a, svar16_b);
1135*f3782652STreehugger Robot fprintf(ref_file, "L_shr(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1136*f3782652STreehugger Robot
1137*f3782652STreehugger Robot
1138*f3782652STreehugger Robot /* shr_r */
1139*f3782652STreehugger Robot /* int16_t shr_r(int16_t x, int16_t y) */
1140*f3782652STreehugger Robot svar16_a = 1;
1141*f3782652STreehugger Robot svar16_b = -1;
1142*f3782652STreehugger Robot Overflow = init_Overflow;
1143*f3782652STreehugger Robot Carry = init_Carry;
1144*f3782652STreehugger Robot svar16_c = shr_r(svar16_a, svar16_b);
1145*f3782652STreehugger Robot fprintf(ref_file, "shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1146*f3782652STreehugger Robot
1147*f3782652STreehugger Robot svar16_a = 10;
1148*f3782652STreehugger Robot svar16_b = -1;
1149*f3782652STreehugger Robot Overflow = init_Overflow;
1150*f3782652STreehugger Robot Carry = init_Carry;
1151*f3782652STreehugger Robot svar16_c = shr_r(svar16_a, svar16_b);
1152*f3782652STreehugger Robot fprintf(ref_file, "shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1153*f3782652STreehugger Robot
1154*f3782652STreehugger Robot svar16_a = 0xFFF;
1155*f3782652STreehugger Robot svar16_b = -10;
1156*f3782652STreehugger Robot Overflow = init_Overflow;
1157*f3782652STreehugger Robot Carry = init_Carry;
1158*f3782652STreehugger Robot svar16_c = shr_r(svar16_a, svar16_b);
1159*f3782652STreehugger Robot fprintf(ref_file, "shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1160*f3782652STreehugger Robot
1161*f3782652STreehugger Robot svar16_a = 0xFFF;
1162*f3782652STreehugger Robot svar16_b = -20;
1163*f3782652STreehugger Robot Overflow = init_Overflow;
1164*f3782652STreehugger Robot Carry = init_Carry;
1165*f3782652STreehugger Robot svar16_c = shr_r(svar16_a, svar16_b);
1166*f3782652STreehugger Robot fprintf(ref_file, "shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1167*f3782652STreehugger Robot
1168*f3782652STreehugger Robot svar16_a = 1;
1169*f3782652STreehugger Robot svar16_b = 1;
1170*f3782652STreehugger Robot Overflow = init_Overflow;
1171*f3782652STreehugger Robot Carry = init_Carry;
1172*f3782652STreehugger Robot svar16_c = shr_r(svar16_a, svar16_b);
1173*f3782652STreehugger Robot fprintf(ref_file, "shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1174*f3782652STreehugger Robot
1175*f3782652STreehugger Robot svar16_a = 20;
1176*f3782652STreehugger Robot svar16_b = 1;
1177*f3782652STreehugger Robot Overflow = init_Overflow;
1178*f3782652STreehugger Robot Carry = init_Carry;
1179*f3782652STreehugger Robot svar16_c = shr_r(svar16_a, svar16_b);
1180*f3782652STreehugger Robot fprintf(ref_file, "shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1181*f3782652STreehugger Robot
1182*f3782652STreehugger Robot svar16_a = 0xFFF;
1183*f3782652STreehugger Robot svar16_b = 10;
1184*f3782652STreehugger Robot Overflow = init_Overflow;
1185*f3782652STreehugger Robot Carry = init_Carry;
1186*f3782652STreehugger Robot svar16_c = shr_r(svar16_a, svar16_b);
1187*f3782652STreehugger Robot fprintf(ref_file, "shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1188*f3782652STreehugger Robot
1189*f3782652STreehugger Robot svar16_a = 0xFFF;
1190*f3782652STreehugger Robot svar16_b = 64;
1191*f3782652STreehugger Robot Overflow = init_Overflow;
1192*f3782652STreehugger Robot Carry = init_Carry;
1193*f3782652STreehugger Robot svar16_c = shr_r(svar16_a, svar16_b);
1194*f3782652STreehugger Robot fprintf(ref_file, "shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1195*f3782652STreehugger Robot
1196*f3782652STreehugger Robot
1197*f3782652STreehugger Robot /* mac_r */
1198*f3782652STreehugger Robot /* int16_t mac_r(int32_t acc, int16_t x, int16_t y) */
1199*f3782652STreehugger Robot svar16_a = 2;
1200*f3782652STreehugger Robot svar16_b = 2;
1201*f3782652STreehugger Robot svar32_a = 0x1234;
1202*f3782652STreehugger Robot Overflow = init_Overflow;
1203*f3782652STreehugger Robot Carry = init_Carry;
1204*f3782652STreehugger Robot svar16_c = mac_r(svar32_a, svar16_a, svar16_b);
1205*f3782652STreehugger Robot fprintf(ref_file, "mac_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1206*f3782652STreehugger Robot
1207*f3782652STreehugger Robot svar16_a = -1;
1208*f3782652STreehugger Robot svar16_b = -1;
1209*f3782652STreehugger Robot Overflow = init_Overflow;
1210*f3782652STreehugger Robot Carry = init_Carry;
1211*f3782652STreehugger Robot svar16_c = mac_r(svar32_a, svar16_a, svar16_b);
1212*f3782652STreehugger Robot fprintf(ref_file, "mac_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1213*f3782652STreehugger Robot
1214*f3782652STreehugger Robot svar16_a = 0x8000;
1215*f3782652STreehugger Robot svar16_b = 0x8000;
1216*f3782652STreehugger Robot Overflow = init_Overflow;
1217*f3782652STreehugger Robot Carry = init_Carry;
1218*f3782652STreehugger Robot svar16_c = mac_r(svar32_a, svar16_a, svar16_b);
1219*f3782652STreehugger Robot fprintf(ref_file, "mac_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1220*f3782652STreehugger Robot
1221*f3782652STreehugger Robot svar16_a = 0x8000;
1222*f3782652STreehugger Robot svar16_b = 0x8000;
1223*f3782652STreehugger Robot Overflow = init_Overflow;
1224*f3782652STreehugger Robot Carry = init_Carry;
1225*f3782652STreehugger Robot svar32_a = -1;
1226*f3782652STreehugger Robot svar16_c = mac_r(svar32_a, svar16_a, svar16_b);
1227*f3782652STreehugger Robot fprintf(ref_file, "mac_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1228*f3782652STreehugger Robot
1229*f3782652STreehugger Robot svar16_a = 0x244;
1230*f3782652STreehugger Robot svar16_b = 0x522;
1231*f3782652STreehugger Robot svar32_a = 0x123456;
1232*f3782652STreehugger Robot Overflow = init_Overflow;
1233*f3782652STreehugger Robot Carry = init_Carry;
1234*f3782652STreehugger Robot svar16_c = mac_r(svar32_a, svar16_a, svar16_b);
1235*f3782652STreehugger Robot fprintf(ref_file, "mac_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1236*f3782652STreehugger Robot
1237*f3782652STreehugger Robot
1238*f3782652STreehugger Robot /* msu_r */
1239*f3782652STreehugger Robot /* int32_t msu_r(int32_t acc, int16_t x, int16_t y) */
1240*f3782652STreehugger Robot svar16_a = 2;
1241*f3782652STreehugger Robot svar16_b = 2;
1242*f3782652STreehugger Robot svar32_a = 0x1234;
1243*f3782652STreehugger Robot Overflow = init_Overflow;
1244*f3782652STreehugger Robot Carry = init_Carry;
1245*f3782652STreehugger Robot svar16_c = msu_r(svar32_a, svar16_a, svar16_b);
1246*f3782652STreehugger Robot fprintf(ref_file, "msu_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1247*f3782652STreehugger Robot
1248*f3782652STreehugger Robot svar16_a = -1;
1249*f3782652STreehugger Robot svar16_b = -1;
1250*f3782652STreehugger Robot Overflow = init_Overflow;
1251*f3782652STreehugger Robot Carry = init_Carry;
1252*f3782652STreehugger Robot svar16_c = msu_r(svar32_a, svar16_a, svar16_b);
1253*f3782652STreehugger Robot fprintf(ref_file, "msu_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1254*f3782652STreehugger Robot
1255*f3782652STreehugger Robot svar16_a = 0x8000;
1256*f3782652STreehugger Robot svar16_b = 0x8000;
1257*f3782652STreehugger Robot Overflow = init_Overflow;
1258*f3782652STreehugger Robot Carry = init_Carry;
1259*f3782652STreehugger Robot svar16_c = msu_r(svar32_a, svar16_a, svar16_b);
1260*f3782652STreehugger Robot fprintf(ref_file, "msu_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1261*f3782652STreehugger Robot
1262*f3782652STreehugger Robot svar16_a = 0x8000;
1263*f3782652STreehugger Robot svar16_b = 0x8000;
1264*f3782652STreehugger Robot svar32_a = 1;
1265*f3782652STreehugger Robot Overflow = init_Overflow;
1266*f3782652STreehugger Robot Carry = init_Carry;
1267*f3782652STreehugger Robot svar16_c = msu_r(svar32_a, svar16_a, svar16_b);
1268*f3782652STreehugger Robot fprintf(ref_file, "msu_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1269*f3782652STreehugger Robot
1270*f3782652STreehugger Robot svar16_a = 0x321;
1271*f3782652STreehugger Robot svar16_b = 0x243;
1272*f3782652STreehugger Robot svar32_a = 0x123456;
1273*f3782652STreehugger Robot Overflow = init_Overflow;
1274*f3782652STreehugger Robot Carry = init_Carry;
1275*f3782652STreehugger Robot svar16_c = msu_r(svar32_a, svar16_a, svar16_b);
1276*f3782652STreehugger Robot fprintf(ref_file, "msu_r(%#x, %#x, %#x) = %#x overflow %d carry %d\n", svar32_a, svar16_a, svar16_b, svar16_c, Overflow, Carry);
1277*f3782652STreehugger Robot
1278*f3782652STreehugger Robot
1279*f3782652STreehugger Robot /* L_deposit_h */
1280*f3782652STreehugger Robot /* int32_t L_deposit_h(int16_t x) */
1281*f3782652STreehugger Robot svar16_b = 1;
1282*f3782652STreehugger Robot Overflow = init_Overflow;
1283*f3782652STreehugger Robot Carry = init_Carry;
1284*f3782652STreehugger Robot svar32_a = L_deposit_h(svar16_b);
1285*f3782652STreehugger Robot fprintf(ref_file, "L_deposit_h(%#x) = %#x overflow %d carry %d\n", svar16_b, svar32_a, Overflow, Carry);
1286*f3782652STreehugger Robot
1287*f3782652STreehugger Robot svar16_b = -1;
1288*f3782652STreehugger Robot Overflow = init_Overflow;
1289*f3782652STreehugger Robot Carry = init_Carry;
1290*f3782652STreehugger Robot svar32_a = L_deposit_h(svar16_b);
1291*f3782652STreehugger Robot fprintf(ref_file, "L_deposit_h(%#x) = %#x overflow %d carry %d\n", svar16_b, svar32_a, Overflow, Carry);
1292*f3782652STreehugger Robot
1293*f3782652STreehugger Robot svar16_b = -32768;
1294*f3782652STreehugger Robot Overflow = init_Overflow;
1295*f3782652STreehugger Robot Carry = init_Carry;
1296*f3782652STreehugger Robot svar32_a = L_deposit_h(svar16_b);
1297*f3782652STreehugger Robot fprintf(ref_file, "L_deposit_h(%#x) = %#x overflow %d carry %d\n", svar16_b, svar32_a, Overflow, Carry);
1298*f3782652STreehugger Robot
1299*f3782652STreehugger Robot svar16_b = 0x1234;
1300*f3782652STreehugger Robot Overflow = init_Overflow;
1301*f3782652STreehugger Robot Carry = init_Carry;
1302*f3782652STreehugger Robot svar32_a = L_deposit_h(svar16_b);
1303*f3782652STreehugger Robot fprintf(ref_file, "L_deposit_h(%#x) = %#x overflow %d carry %d\n", svar16_b, svar32_a, Overflow, Carry);
1304*f3782652STreehugger Robot
1305*f3782652STreehugger Robot
1306*f3782652STreehugger Robot /* L_deposit_l */
1307*f3782652STreehugger Robot /* int32_t L_deposit_l(int16_t x) */
1308*f3782652STreehugger Robot svar16_b = 1;
1309*f3782652STreehugger Robot Overflow = init_Overflow;
1310*f3782652STreehugger Robot Carry = init_Carry;
1311*f3782652STreehugger Robot svar32_a = L_deposit_l(svar16_b);
1312*f3782652STreehugger Robot fprintf(ref_file, "L_deposit_l(%#x) = %#x overflow %d carry %d\n", svar16_b, svar32_a, Overflow, Carry);
1313*f3782652STreehugger Robot
1314*f3782652STreehugger Robot svar16_b = -1;
1315*f3782652STreehugger Robot Overflow = init_Overflow;
1316*f3782652STreehugger Robot Carry = init_Carry;
1317*f3782652STreehugger Robot svar32_a = L_deposit_l(svar16_b);
1318*f3782652STreehugger Robot fprintf(ref_file, "L_deposit_l(%#x) = %#x overflow %d carry %d\n", svar16_b, svar32_a, Overflow, Carry);
1319*f3782652STreehugger Robot
1320*f3782652STreehugger Robot svar16_b = -32768;
1321*f3782652STreehugger Robot Overflow = init_Overflow;
1322*f3782652STreehugger Robot Carry = init_Carry;
1323*f3782652STreehugger Robot svar32_a = L_deposit_l(svar16_b);
1324*f3782652STreehugger Robot fprintf(ref_file, "L_deposit_l(%#x) = %#x overflow %d carry %d\n", svar16_b, svar32_a, Overflow, Carry);
1325*f3782652STreehugger Robot
1326*f3782652STreehugger Robot svar16_b = 0x1234;
1327*f3782652STreehugger Robot Overflow = init_Overflow;
1328*f3782652STreehugger Robot Carry = init_Carry;
1329*f3782652STreehugger Robot svar32_a = L_deposit_l(svar16_b);
1330*f3782652STreehugger Robot fprintf(ref_file, "L_deposit_l(%#x) = %#x overflow %d carry %d\n", svar16_b, svar32_a, Overflow, Carry);
1331*f3782652STreehugger Robot
1332*f3782652STreehugger Robot
1333*f3782652STreehugger Robot /* L_shr_r */
1334*f3782652STreehugger Robot /* int32_t L_shr_r(int32_t x, int16_t y) */
1335*f3782652STreehugger Robot svar32_a = 1;
1336*f3782652STreehugger Robot svar16_b = -1;
1337*f3782652STreehugger Robot Overflow = init_Overflow;
1338*f3782652STreehugger Robot Carry = init_Carry;
1339*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1340*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1341*f3782652STreehugger Robot
1342*f3782652STreehugger Robot svar32_a = 10;
1343*f3782652STreehugger Robot svar16_b = -1;
1344*f3782652STreehugger Robot Overflow = init_Overflow;
1345*f3782652STreehugger Robot Carry = init_Carry;
1346*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1347*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1348*f3782652STreehugger Robot
1349*f3782652STreehugger Robot svar32_a = 0xFFF;
1350*f3782652STreehugger Robot svar16_b = -10;
1351*f3782652STreehugger Robot Overflow = init_Overflow;
1352*f3782652STreehugger Robot Carry = init_Carry;
1353*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1354*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1355*f3782652STreehugger Robot
1356*f3782652STreehugger Robot svar32_a = 0xFFF;
1357*f3782652STreehugger Robot svar16_b = -20;
1358*f3782652STreehugger Robot Overflow = init_Overflow;
1359*f3782652STreehugger Robot Carry = init_Carry;
1360*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1361*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1362*f3782652STreehugger Robot
1363*f3782652STreehugger Robot svar32_a = 0x12345678;
1364*f3782652STreehugger Robot svar16_b = -10;
1365*f3782652STreehugger Robot Overflow = init_Overflow;
1366*f3782652STreehugger Robot Carry = init_Carry;
1367*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1368*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1369*f3782652STreehugger Robot
1370*f3782652STreehugger Robot svar32_a = 0x12345678;
1371*f3782652STreehugger Robot svar16_b = -40;
1372*f3782652STreehugger Robot Overflow = init_Overflow;
1373*f3782652STreehugger Robot Carry = init_Carry;
1374*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1375*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1376*f3782652STreehugger Robot
1377*f3782652STreehugger Robot svar32_a = 1;
1378*f3782652STreehugger Robot svar16_b = 1;
1379*f3782652STreehugger Robot Overflow = init_Overflow;
1380*f3782652STreehugger Robot Carry = init_Carry;
1381*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1382*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1383*f3782652STreehugger Robot
1384*f3782652STreehugger Robot svar32_a = 20;
1385*f3782652STreehugger Robot svar16_b = 1;
1386*f3782652STreehugger Robot Overflow = init_Overflow;
1387*f3782652STreehugger Robot Carry = init_Carry;
1388*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1389*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1390*f3782652STreehugger Robot
1391*f3782652STreehugger Robot svar32_a = 0xFFF;
1392*f3782652STreehugger Robot svar16_b = 10;
1393*f3782652STreehugger Robot Overflow = init_Overflow;
1394*f3782652STreehugger Robot Carry = init_Carry;
1395*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1396*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1397*f3782652STreehugger Robot
1398*f3782652STreehugger Robot svar32_a = 0xFFF;
1399*f3782652STreehugger Robot svar16_b = 64;
1400*f3782652STreehugger Robot Overflow = init_Overflow;
1401*f3782652STreehugger Robot Carry = init_Carry;
1402*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1403*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1404*f3782652STreehugger Robot
1405*f3782652STreehugger Robot svar32_a = 0x12345678;
1406*f3782652STreehugger Robot svar16_b = 10;
1407*f3782652STreehugger Robot Overflow = init_Overflow;
1408*f3782652STreehugger Robot Carry = init_Carry;
1409*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1410*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1411*f3782652STreehugger Robot
1412*f3782652STreehugger Robot svar32_a = 0x12345678;
1413*f3782652STreehugger Robot svar16_b = 64;
1414*f3782652STreehugger Robot Overflow = init_Overflow;
1415*f3782652STreehugger Robot Carry = init_Carry;
1416*f3782652STreehugger Robot svar32_c = L_shr_r(svar32_a, svar16_b);
1417*f3782652STreehugger Robot fprintf(ref_file, "L_shr_r(%#x, %d) = %#x overflow %d carry %d\n", svar32_a, svar16_b, svar32_c, Overflow, Carry);
1418*f3782652STreehugger Robot
1419*f3782652STreehugger Robot
1420*f3782652STreehugger Robot /* L_abs */
1421*f3782652STreehugger Robot /* int32_t L_abs(int32_t x) */
1422*f3782652STreehugger Robot svar32_b = 1;
1423*f3782652STreehugger Robot Overflow = init_Overflow;
1424*f3782652STreehugger Robot Carry = init_Carry;
1425*f3782652STreehugger Robot svar32_a = L_abs(svar32_b);
1426*f3782652STreehugger Robot fprintf(ref_file, "L_abs(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
1427*f3782652STreehugger Robot
1428*f3782652STreehugger Robot svar32_b = -1;
1429*f3782652STreehugger Robot Overflow = init_Overflow;
1430*f3782652STreehugger Robot Carry = init_Carry;
1431*f3782652STreehugger Robot svar32_a = L_abs(svar32_b);
1432*f3782652STreehugger Robot fprintf(ref_file, "L_abs(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
1433*f3782652STreehugger Robot
1434*f3782652STreehugger Robot svar32_b = 0x80000000;
1435*f3782652STreehugger Robot Overflow = init_Overflow;
1436*f3782652STreehugger Robot Carry = init_Carry;
1437*f3782652STreehugger Robot svar32_a = L_abs(svar32_b);
1438*f3782652STreehugger Robot fprintf(ref_file, "L_abs(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
1439*f3782652STreehugger Robot
1440*f3782652STreehugger Robot
1441*f3782652STreehugger Robot /* L_sat */
1442*f3782652STreehugger Robot /* int32_t L_sat(int32_t x) */
1443*f3782652STreehugger Robot svar32_b = 1;
1444*f3782652STreehugger Robot Overflow = init_Overflow;
1445*f3782652STreehugger Robot Carry = init_Carry;
1446*f3782652STreehugger Robot svar32_a = L_sat(svar32_b);
1447*f3782652STreehugger Robot fprintf(ref_file, "L_sat(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
1448*f3782652STreehugger Robot
1449*f3782652STreehugger Robot svar32_b = -1;
1450*f3782652STreehugger Robot Overflow = init_Overflow;
1451*f3782652STreehugger Robot Carry = init_Carry;
1452*f3782652STreehugger Robot svar32_a = L_sat(svar32_b);
1453*f3782652STreehugger Robot fprintf(ref_file, "L_sat(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
1454*f3782652STreehugger Robot
1455*f3782652STreehugger Robot svar32_b = -32768;
1456*f3782652STreehugger Robot Overflow = init_Overflow;
1457*f3782652STreehugger Robot Carry = init_Carry;
1458*f3782652STreehugger Robot svar32_a = L_sat(svar32_b);
1459*f3782652STreehugger Robot fprintf(ref_file, "L_sat(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
1460*f3782652STreehugger Robot
1461*f3782652STreehugger Robot svar32_b = 32768;
1462*f3782652STreehugger Robot Overflow = init_Overflow;
1463*f3782652STreehugger Robot Carry = init_Carry;
1464*f3782652STreehugger Robot svar32_a = L_sat(svar32_b);
1465*f3782652STreehugger Robot fprintf(ref_file, "L_sat(%#x) = %#x overflow %d carry %d\n", svar32_b, svar32_a, Overflow, Carry);
1466*f3782652STreehugger Robot
1467*f3782652STreehugger Robot
1468*f3782652STreehugger Robot /* div_s */
1469*f3782652STreehugger Robot /* int16_t div_s(int16_t x, int16_t y) */
1470*f3782652STreehugger Robot svar16_a = 1;
1471*f3782652STreehugger Robot svar16_b = 1;
1472*f3782652STreehugger Robot Overflow = init_Overflow;
1473*f3782652STreehugger Robot Carry = init_Carry;
1474*f3782652STreehugger Robot svar16_c = div_s(svar16_a, svar16_b);
1475*f3782652STreehugger Robot fprintf(ref_file, "div_s(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1476*f3782652STreehugger Robot
1477*f3782652STreehugger Robot svar16_a = 10000;
1478*f3782652STreehugger Robot svar16_b = 20000;
1479*f3782652STreehugger Robot Overflow = init_Overflow;
1480*f3782652STreehugger Robot Carry = init_Carry;
1481*f3782652STreehugger Robot svar16_c = div_s(svar16_a, svar16_b);
1482*f3782652STreehugger Robot fprintf(ref_file, "div_s(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1483*f3782652STreehugger Robot
1484*f3782652STreehugger Robot
1485*f3782652STreehugger Robot svar16_a = 10000;
1486*f3782652STreehugger Robot svar16_b = 20000;
1487*f3782652STreehugger Robot Overflow = init_Overflow;
1488*f3782652STreehugger Robot Carry = init_Carry;
1489*f3782652STreehugger Robot svar16_c = div_s(svar16_a, svar16_b);
1490*f3782652STreehugger Robot fprintf(ref_file, "div_s(%#x, %#x) = %#x overflow %d carry %d\n", svar16_a, svar16_b, svar16_c, Overflow, Carry);
1491*f3782652STreehugger Robot
1492*f3782652STreehugger Robot }
1493*f3782652STreehugger Robot
exec_dspfns(void)1494*f3782652STreehugger Robot void exec_dspfns(void)
1495*f3782652STreehugger Robot {
1496*f3782652STreehugger Robot Overflow = 0;
1497*f3782652STreehugger Robot
1498*f3782652STreehugger Robot exec_dspfns1(0, 0);
1499*f3782652STreehugger Robot exec_dspfns1(0, 1);
1500*f3782652STreehugger Robot exec_dspfns1(1, 0);
1501*f3782652STreehugger Robot exec_dspfns1(1, 1);
1502*f3782652STreehugger Robot }
1503