comparison intercom/gsm/add_test.dta @ 2:13be24d74cd2

import intercom-0.4.1
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 09:57:52 +0200
parents
children
comparison
equal deleted inserted replaced
1:9cadc470e3da 2:13be24d74cd2
1 ;
2 ; Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
3 ; Universitaet Berlin. See the accompanying file "COPYRIGHT" for
4 ; details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
5 ;
6 ;
7 ; Lines starting with ' (in the first col) are echoed.
8 ; Lines starting with " (in the first col) are echoed to stderr.
9 ; Lines starting with ; or empty lines are ignored.
10 ;
11 ; The part after (including) a trailing '=' is what you expect;
12 ; there will be output if the result is different.
13 ;
14 ; - and + by itself mean MIN_WORD and MAX_WORD, respectively;
15 ; -- and ++ mean MIN_LONGWORD and MAX_LONGWORD.
16 ;
17
18 'test the basic arithmetic operations used for the rpe-ltd filtering.
19 '
20 'add ================
21 ' basic
22
23 add 0 0 = 0
24 add 7 4 = 11
25 add 4 6 = 10
26 add 1 1 = 2
27
28 ' negative operands
29
30 add -7 4 = -3
31 add 4 -6 = -2
32 add -1 -3 = -4
33 add 7 -4 = 3
34 add -4 6 = 2
35
36 ' positive overflow
37 ; (max-word = 32767)
38 add + 1 = +
39 add + + = +
40 add -1 + = 32766
41 add 32766 2 = +
42 add 1 32766 = +
43
44 ' underflow
45 ; (min-word = 32768)
46
47 add - -1 = -
48 add - - = -
49 add 1 - = -32767
50 add -32767 -2 = -
51 add -1 -32766 = -32767
52 add -32767 -1 = -
53 add - + = -1
54 add + - = -1
55 add 0 - = -
56 add 0 + = +
57 '
58
59 'L_add ================
60 ' basic
61
62 L_add 0 0 = 0
63 L_add 7 4 = 11
64 L_add 4 6 = 10
65 L_add 1 1 = 2
66
67 ' negative operands
68
69 L_add -7 4 = -3
70 L_add 4 -6 = -2
71 L_add -1 -3 = -4
72 L_add 7 -4 = 3
73 L_add -4 6 = 2
74 L_add 0 -1 = -1
75
76 ' positive overflow
77 ; (max-longword = 2147483647)
78 L_add ++ 1 = ++
79 L_add ++ ++ = ++
80 L_add -1 ++ = 2147483646
81 L_add 2147483646 2 = ++
82 L_add 1 2147483645 = 2147483646
83
84 ' underflow
85 ; (min-longword = -2147483648)
86
87 L_add -- -1 = --
88 L_add -- -- = --
89 L_add 1 -- = -2147483647
90 L_add -2147483647 -2 = --
91 L_add -1 -2147483646 = -2147483647
92 L_add -2147483647 -1 = --
93 L_add -- ++ = -1
94 L_add ++ -- = -1
95 L_add 0 -- = --
96 L_add 0 ++ = ++
97 '
98
99 'sub ================
100 ' basic
101
102 sub 0 0 = 0
103 sub 7 4 = 3
104 sub 4 6 = -2
105 sub 1 0 = 1
106
107 ' negative operands
108
109 sub -7 4 = -11
110 sub 4 -6 = 10
111 sub -1 -3 = 2
112 sub 7 -4 = 11
113 sub -4 6 = -10
114
115 ' positive overflow
116 ; (max-word = 32767)
117 sub 1 - = +
118 sub + + = 0
119 sub + 0 = +
120 sub + -1 = +
121 sub + 1 = 32766
122 sub 1 + = -32766
123 sub 0 + = -32767
124
125 ' underflow
126 ; (min-word = 32768)
127
128 sub - -1 = -32767
129 sub - 1 = -
130 sub - - = 0
131 sub - + = -
132 sub + - = +
133 sub 1 - = +
134 sub -1 - = +
135 sub -32767 2 = -
136 sub 0 - = +
137 '
138
139 'L_sub ================
140 ' basic
141
142 L_sub 0 0 = 0
143 L_sub 7 4 = 3
144 L_sub 4 6 = -2
145 L_sub 1 0 = 1
146
147 ' negative operands
148
149 L_sub -7 4 = -11
150 L_sub 4 -6 = 10
151 L_sub -1 -3 = 2
152 L_sub 7 -4 = 11
153 L_sub -4 6 = -10
154
155 ' positive overflow
156 L_sub 1 -- = ++
157 L_sub ++ ++ = 0
158 L_sub ++ 0 = ++
159 L_sub ++ -1 = ++
160 L_sub ++ 1 = 2147483646
161 L_sub 1 ++ = -2147483646
162 L_sub 0 ++ = -2147483647
163
164 ' underflow
165
166 L_sub -- -1 = -2147483647
167 L_sub -- 1 = --
168 L_sub -- -- = 0
169 L_sub -- ++ = --
170 L_sub + -- = ++
171 L_sub 1 -- = ++
172 L_sub -1 -- = ++
173 L_sub -2147483647 2 = --
174 L_sub 0 -- = ++
175
176 '
177 'abs ================
178 ' basic
179
180 abs 0 = 0
181 abs 2 = 2
182 abs -459 = 459
183
184 ' overflow
185
186 abs + = +
187 abs - = +
188 abs -32767 = +
189 abs 32766 = 32766
190 abs -32766 = 32766
191
192 '
193 'mult ================
194 ; actually, a * b >> 15
195
196 ' basic
197 mult 0 0 = 0
198 mult 0x100 0x100 = 2
199 mult 4711 0x4000 = 2355
200
201 ' negative operands
202 mult -1 0 = 0
203
204 mult -0x100 0x100 = -2
205 mult 0x100 -0x100 = -2
206 mult -0x100 -0x100 = 2
207
208 mult -4711 0x4000 = -2356
209 mult 4711 -0x4000 = -2356
210 mult -4711 -0x4000 = 2355
211
212 ' overflow
213 mult + + = 32766
214 mult + 0x4000 = 0x3fff
215 mult 0x4000 + = 0x3fff
216 mult + 1 = 0
217 mult + 2 = 1
218 mult + 3 = 2
219
220 ' underflow
221 mult - - = +
222 mult - + = -32767
223 mult + - = -32767
224 mult - 1 = -1
225 mult - 2 = -2
226 mult - 3 = -3
227
228 '
229 'mult_r ================
230 ; actually, (a * b + 16384) >> 15
231
232 ' basic
233 mult_r 0 0 = 0
234 mult_r 0x100 0x100 = 2
235 mult_r 4711 0x4000 = 2356
236
237 ' negative operands
238 mult_r -1 0 = 0
239
240 mult_r -0x100 0x100 = -2
241 mult_r 0x100 -0x100 = -2
242 mult_r -0x100 -0x100 = 2
243
244 mult_r -4711 0x4000 = -2355
245 mult_r 4711 -0x4000 = -2355
246 mult_r -4711 -0x4000 = 2356
247
248 ' overflow
249 mult_r + + = 32766
250 mult_r + 32766 = 32765
251 mult_r 32766 + = 32765
252 mult_r + 0x4000 = 0x4000
253 mult_r 0x4000 + = 0x4000
254 mult_r + 0x4001 = 0x4000
255 mult_r 0x4001 + = 0x4000
256 mult_r + 2 = 2
257 mult_r + 1 = 1
258 mult_r 1 + = 1
259 mult_r + 0 = 0
260 mult_r 0 + = 0
261
262 ' underflow
263 mult_r - - = +
264 mult_r - + = -32767
265 mult_r + - = -32767
266 mult_r - 1 = -1
267 mult_r - 2 = -2
268 mult_r - 3 = -3
269
270 '
271 'L_mult ================
272 ; actually, (a * b) << 1
273 ; assert (a != MIN_WORD && b != MIN_WORD)
274
275 ' basic
276 L_mult 0 0 = 0
277 L_mult 2 3 = 12
278 L_mult 4711 5 = 47110
279
280 ' negative operands
281
282 L_mult -2 3 = -12
283 L_mult 2 -3 = -12
284 L_mult -2 -3 = 12
285 L_mult -4711 5 = -47110
286 L_mult 4711 -5 = -47110
287 L_mult -4711 -5 = 47110
288
289 ' overflow
290 L_mult + + = 2147352578
291 L_mult + -32767 = -2147352578
292 L_mult -32767 + = -2147352578
293 L_mult + 2 = 131068
294 L_mult + 1 = 65534
295 L_mult 1 + = 65534
296 L_mult + 0 = 0
297 L_mult 0 + = 0
298
299 '
300 'div ================
301 ; actually, (32767 * a) / b
302 ; assert (a > 0 && b >= a)
303
304 ' basic
305 div 1 1 = +
306 div 4711 4711 = +
307 div 5 10 = 0x4000
308 div 5 20 = 0x2000
309 div 5 40 = 0x1000
310
311 ' overflow
312 div + + = +
313 div 0x4000 + = 0x4000
314 div 1 + = 1
315 div 1 2 = 0x4000
316 '
317 'norm ================
318
319 ' positive
320 norm 1 = 30
321 norm 2 = 29
322 norm 3 = 29
323 norm 4 = 28
324 norm 5 = 28
325 ; etc, etc...
326 norm 0x08000000 = 3
327 norm 0x10000000 = 2
328 norm 0x20000000 = 1
329 norm 0x20000001 = 1
330 norm 0x3fffffff = 1
331 norm 0x40000000 = 0
332 norm 0x40000001 = 0
333 norm 0x4ffffffe = 0
334 norm ++ = 0
335
336 ' negative
337 norm -1 = 31
338 norm -2 = 30
339 norm -3 = 29
340 norm -4 = 29
341 norm -5 = 28
342 ; etc, etc...
343 norm 0x4fffffff = 0
344 norm -- = 0
345 '
346 '>> ================
347
348 ' basic
349 >> 1 1 = 0
350 >> 4 2 = 1
351 >> 0x1100 5 = 0x88
352
353 ' negative operand
354
355 >> 1 -1 = 2
356 >> 1 -2 = 4
357 >> 0x88 -5 = 0x1100
358
359 ' overflow
360 >> -1 4711 = -1
361 >> 1 4711 = 0
362 >> -4711 4711 = -1
363 >> 4711 4711 = 0
364 >> + 1 = 16383
365 >> - 1 = -16384
366 '
367 'L_>> ================
368
369 ' basic
370 L_>> 1 1 = 0
371 L_>> 4 2 = 1
372 L_>> 0x1100 5 = 0x88
373
374 ' negative operand
375
376 L_>> 1 -1 = 2
377 L_>> 1 -2 = 4
378 L_>> 0x88 -5 = 0x1100
379
380 ' overflow
381 L_>> -1 4711 = -1
382 L_>> 1 4711 = 0
383 L_>> -4711 4711 = -1
384 L_>> 4711 4711 = 0
385 L_>> ++ 1 = 1073741823
386 L_>> -- 1 = -1073741824
387
388 '
389 '<< ================
390
391 ' basic
392 << 1 1 = 2
393 << 4 2 = 16
394 << 0x0088 5 = 0x1100
395
396 ' negative operand
397
398 << 1 -1 = 0
399 << 4 -2 = 1
400 << 0x1100 -5 = 0x0088
401
402 ' overflow
403 << -1 4711 = 0
404 << 1 4711 = 0
405 << -4711 4711 = 0
406 << 4711 4711 = 0
407 << 4711 -4711 = 0
408 << -4711 -4711 = -1
409 << + 1 = 0xfffe
410 << -1 1 = 0xfffe
411 << - 1 = 0
412 '
413 'L_<< ================
414
415 ' basic
416 L_<< 1 1 = 2
417 L_<< 4 2 = 16
418 L_<< 0x0088 5 = 0x1100
419
420 ' negative operand
421
422 L_<< 1 -1 = 0
423 L_<< 4 -2 = 1
424 L_<< 0x1100 -5 = 0x0088
425
426 ' overflow
427 L_<< -1 4711 = 0
428 L_<< 1 4711 = 0
429 L_<< -4711 4711 = 0
430 L_<< 4711 4711 = 0
431 L_<< 4711 -4711 = 0
432 L_<< -4711 -4711 = -1
433 L_<< ++ 1 = -2
434 L_<< -1 1 = -2
435 L_<< -- 1 = 0

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.