OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-ov.S] - Blame information for rev 820

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 502 julius
/*
2
        OR1200 overflow bit checking
3
 
4
        Very basic, testing
5
 
6
TODO:    Check range exception handling in delay slots
7
 
8
        Julius Baxter, ORSoC AB, julius.baxter@orsoc.se
9
 
10
*/
11
//////////////////////////////////////////////////////////////////////
12
////                                                              ////
13
//// Copyright (C) 2011 Authors and OPENCORES.ORG                 ////
14
////                                                              ////
15
//// This source file may be used and distributed without         ////
16
//// restriction provided that this copyright statement is not    ////
17
//// removed from the file and that any derivative work contains  ////
18
//// the original copyright notice and the associated disclaimer. ////
19
////                                                              ////
20
//// This source file is free software; you can redistribute it   ////
21
//// and/or modify it under the terms of the GNU Lesser General   ////
22
//// Public License as published by the Free Software Foundation; ////
23
//// either version 2.1 of the License, or (at your option) any   ////
24
//// later version.                                               ////
25
////                                                              ////
26
//// This source is distributed in the hope that it will be       ////
27
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
28
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
29
//// PURPOSE.  See the GNU Lesser General Public License for more ////
30
//// details.                                                     ////
31
////                                                              ////
32
//// You should have received a copy of the GNU Lesser General    ////
33
//// Public License along with this source; if not, download it   ////
34
//// from http://www.opencores.org/lgpl.shtml                     ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
 
38
 
39
#include "spr-defs.h"
40
#include "board.h"
41
#include "or1200-defines.h"
42
 
43
 
44
/* =================================================== [ exceptions ] === */
45
        .section .vectors, "ax"
46
 
47
 
48
/* ---[ 0x100: RESET exception ]----------------------------------------- */
49
        .org 0x100
50
        l.movhi r0, 0
51
        /* Clear status register */
52
        l.ori r1, r0, SPR_SR_SM
53
        l.mtspr r0, r1, SPR_SR
54
        /* Clear timer  */
55
        l.mtspr r0, r0, SPR_TTMR
56
 
57
        /* Jump to program initialisation code */
58
        .global _start
59
        l.movhi r4, hi(_start)
60
        l.ori r4, r4, lo(_start)
61
        l.jr    r4
62
        l.nop
63
 
64
        .org 0x600
65
        l.nop 0x1
66
 
67
 
68
/* ---[ 0x700: Illegal instruction exception ]-------------------------- */
69
        .org 0x700
70
#ifndef OR1200_IMPL_ADDC
71
        // No problem - instruction not supported
72
        l.movhi r3, hi(0x8000000d)
73
        l.ori   r3, r3, lo(0x8000000d)
74
        l.nop   0x2
75
        l.ori   r3, r0, 0
76
#else
77
        l.ori   r3, r0, 1
78
#endif
79
        l.nop   0x1
80
 
81
#define INCREMENT_EXCEPTION_COUNTER     l.addi r11, r11, 0x1
82
#define CHECK_EXCEPTION_COUNTER         \
83
        l.sfne  r11, r12        ;       \
84
        l.bf    _fail           ;       \
85
        l.nop                   ;
86
#define EXPECT_RANGE_EXCEPT             \
87
        l.addi  r12, r12, 1     ;       \
88
        CHECK_EXCEPTION_COUNTER
89
 
90
/* ---[ 0xb00: Range exception ]---------------------------------------- */
91
        .org 0xb00
92
        l.sw    0(r0), r3       ;// Save r3 - don't disrupt it during exceptions
93
        l.ori   r3, r0, 0xaaee
94
        l.nop   0x2
95
        // TODO - get instruction and decode to ensure it was an instruction
96
        // which is capable of causing a range exception. Remember delay slot!
97
        INCREMENT_EXCEPTION_COUNTER
98
 
99
        // Clear OV in ESR
100
        l.mfspr r3,r0,SPR_ESR_BASE      ;// Get ESR
101
        l.nop   2
102
        l.xori  r3, r3,SPR_SR_OV        ;// Clear OV bit
103
        l.mtspr r0,r3,SPR_ESR_BASE      ;// Get EPC
104
 
105
        l.mfspr r3,r0,SPR_EPCR_BASE     ;// Get EPC
106
        l.nop   2
107
        l.addi  r3, r3, 0x4             ;// Increment
108
        l.mtspr r0,r3,SPR_EPCR_BASE     ;// Get EPC
109
        // For now, increment EPCR so we step over instruction and continue
110
 
111
        l.lwz   r3, 0(r0)
112
        l.rfe
113
 
114
/* =================================================== [ text ] === */
115
        .section .text
116
 
117
/* =================================================== [ start ] === */
118
 
119
        .global _start
120
_start:
121
        // Clear all regs
122
        l.movhi r1, 0
123
        l.movhi r2, 0
124
        l.movhi r3, 0
125
        l.movhi r4, 0
126
        l.movhi r5, 0
127
        l.movhi r6, 0
128
        l.movhi r7, 0
129
        l.movhi r8, 0
130
        l.movhi r9, 0
131
        l.movhi r10, 0
132
        l.movhi r11, 0
133
        l.movhi r12, 0
134
        l.movhi r13, 0
135
        l.movhi r14, 0
136
        l.movhi r15, 0
137
        l.movhi r16, 0
138
        l.movhi r17, 0
139
        l.movhi r18, 0
140
        l.movhi r19, 0
141
        l.movhi r20, 0
142
        l.movhi r21, 0
143
        l.movhi r22, 0
144
        l.movhi r23, 0
145
        l.movhi r24, 0
146
        l.movhi r25, 0
147
        l.movhi r26, 0
148
        l.movhi r27, 0
149
        l.movhi r28, 0
150
        l.movhi r29, 0
151
        l.movhi r30, 0
152
        l.movhi r31, 0
153
 
154
#ifdef OR1200_IMPL_OV
155
        // Kick off test
156
        l.jal   _main
157
#else
158
        // Not supported, exit test
159
        l.j     _finish
160
#endif
161
        l.nop
162
 
163
 
164
/* =================================================== [ main ] === */
165
 
166
 
167
#define CHECK_OV_CLEAR                  \
168
        l.mfspr r20, r0, SPR_SR ;       \
169
        l.andi  r21, r20, SPR_SR_OV ;   \
170
        l.sfne  r21, r0           ;     \
171
        l.bf    _fail             ;     \
172
        l.nop
173
 
174
#define CHECK_OV_SET                    \
175
        l.mfspr r20, r0, SPR_SR ;       \
176
        l.andi  r21, r20, SPR_SR_OV ;   \
177
        l.sfnei r21, SPR_SR_OV    ;     \
178
        l.bf    _fail             ;     \
179
        l.addi  r12, r12, 0x1     ;     // Increment expected counter
180
 
181
        .global _main
182
_main:
183
 
184
        // Set up some values, check the OV bit is cleared
185
        CHECK_OV_CLEAR
186
 
187
        l.movhi r4, 0x7fff
188
        l.ori   r4, r4, 0xefff
189
 
190
        l.ori   r5, r0, 0xffff
191
 
192
        l.add   r3, r5, r4      ;// Should set overflow
193
        l.nop   0x2
194
        CHECK_OV_SET
195
 
196
        l.add   r3, r0, r0      ;// Should clear overflow
197
        l.nop   0x2
198
        CHECK_OV_CLEAR
199
 
200
        l.addi  r3, r4, 0x7fff  ;// Should set overflow
201
        l.nop   0x2
202
        CHECK_OV_SET
203
 
204
        l.add   r3, r0, r0      ;// Should clear overflow
205
        l.nop   0x2
206
        CHECK_OV_CLEAR
207
 
208
        // Now test negative numbers
209
 
210
        l.movhi r4, 0x8000
211
        l.ori   r4, r4, 0x0000
212
 
213
        l.movhi r5, 0xffff
214
        l.ori   r5, r5, 0xffff
215
 
216
        l.add   r3, r4, r5      // Biggest and smallest negative number
217
        l.nop   0x2
218
        CHECK_OV_SET
219
 
220
        l.add   r3, r0, r0      ;// Should clear overflow
221
        l.nop   0x2
222
        CHECK_OV_CLEAR
223
 
224
        l.addi  r3, r4, 0xffff  // Biggest and smallest negative number
225
        l.nop   0x2
226
        CHECK_OV_SET
227
 
228
        l.add   r3, r0, r0      ;// Should clear overflow
229
        l.nop   0x2
230
        CHECK_OV_CLEAR
231
 
232
        l.add   r3, r4, r0      // Biggest negative number, and zero
233
        l.nop   0x2
234
        CHECK_OV_CLEAR
235
 
236
        l.add   r3, r0, r0      ;// Should clear overflow
237
        l.nop   0x2
238
        CHECK_OV_CLEAR
239
 
240
        l.movhi r5, 0xffff
241
        l.ori   r5, r5, 0xfffe
242
 
243
        l.add   r3, r4, r5      // Biggest and second smallest negative number
244
        l.nop   0x2
245
        CHECK_OV_SET
246
 
247
        l.add   r3, r0, r0      ;// Should clear overflow
248
        l.nop   0x2
249
        CHECK_OV_CLEAR
250
 
251
#ifdef OR1200_IMPL_SUB
252
 
253
        // report indicator that we're at l.sub section 0x55555555
254
        l.movhi r3, 0x5555
255
        l.ori   r3, r3, 0x5555
256
        l.nop   0x2
257
 
258
        // Quick subtract check
259
        // Check largest negative number -1 tripping overflow
260
        l.ori   r5, r0, 1               ; // +1
261
        l.sub   r3, r4, r5              ; // -2147483647 - 1
262
        l.nop   0x2
263
        CHECK_OV_SET
264
 
265
        l.add   r3, r0, r0      ;// Should clear overflow
266
        l.nop   0x2
267
        CHECK_OV_CLEAR
268 803 julius
 
269
        // Subtract the biggest negative number from the
270
        // biggest positive number.
271
        l.movhi r4,0x7fff
272
        l.ori   r4,r4,0xffff
273
        l.movhi r5,0x8000
274
        l.sub   r3,r4,r5
275
        l.nop   2
276
        CHECK_OV_SET
277
 
278 502 julius
#endif
279
 
280
        l.movhi r4, 0x8000
281
        l.ori   r4, r4, 0x0437
282
 
283
        l.movhi r5, 0xffff
284
        l.ori   r5, r5, 0xfbc7
285
 
286
        l.add   r3, r4, r5      // Very big negative number, another one big
287
                                // enough to cause overflow hopefully
288
        l.nop   0x2
289
        CHECK_OV_SET
290
 
291
        l.add   r3, r0, r0      ;// Should clear overflow
292
        l.nop   0x2
293
        CHECK_OV_CLEAR
294
 
295
        l.movhi r5, 0xffff
296
        l.ori   r5, r5, 0xfff7
297
 
298
        l.add   r3, r4, r5      // Two negative numbers but shouldn't overflow
299
        l.nop   0x2
300
        CHECK_OV_CLEAR
301
 
302
#ifdef OR1200_DIV_IMPLEMENTED
303
 
304
        // report indicator that we're at l.div section 0xdddddddd
305
        l.movhi r3, 0xdddd
306
        l.ori   r3, r3, 0xdddd
307
        l.nop   0x2
308
 
309
        // Test divide by zero
310
        l.div   r3, r5, r0
311
        l.nop   0x2
312
 
313
        l.sfne  r3, r0          ;// Check result was 0
314
        l.bf    _fail
315
 
316
        CHECK_OV_SET
317
 
318
        l.add   r3, r5, r0      ;// Should clear overflow
319
        l.nop   0x2
320
 
321
        CHECK_OV_CLEAR
322
 
323
        // Test divide by zero
324
        l.divu  r3, r0, r0
325
        l.nop   0x2
326
        CHECK_OV_SET
327
 
328
        l.sfne  r3, r0          ;// Check result was 0
329
        l.bf    _fail
330
 
331
        l.add   r3, r0, r0      ;// Should clear overflow
332
        l.nop   0x2
333
        CHECK_OV_CLEAR
334
 
335
#endif
336
 
337
#ifdef OR1200_MULT_IMPLEMENTED
338
 
339
        // report indicator that we're at l.multiply section 0x11111111
340
        l.movhi r3, 0x1111
341
        l.ori   r3, r3, 0x1111
342
        l.nop   0x2
343
 
344
        // Check multiplying two large numbers, which will cause overflow,
345
        // trigger the flag appropriately
346
 
347
        // First signed multiply.
348
        l.movhi r4, 0xd555      ;//-(((2^32)-1)/3 + 2)
349
        l.ori   r4, r4, 0x5552
350
        l.ori   r5, r0, 2
351
        l.ori   r6, r0, 3
352
 
353
        // First multiply big negative number by 2 - shouldn't overflow
354
        l.mul   r3, r4, r5
355
        l.nop   0x2
356
        CHECK_OV_CLEAR
357
 
358
        // Now multiply by 3 - should just overflow negative
359
        l.mul   r3, r4, r6
360
        l.nop   0x2
361
        CHECK_OV_SET
362
 
363
        l.add   r3, r0, r0      ;// Should clear overflow
364
        l.nop   0x2
365
        CHECK_OV_CLEAR
366
 
367
        // Now some big positive values
368
        l.movhi r4, 0x2aaa      ;//((2^32)-1)/3 + 2
369
        l.ori   r4, r4, 0xaaae
370
        l.ori   r5, r0, 2
371
        l.ori   r6, r0, 3
372
 
373
        // First multiply big number by 2 - shouldn't overflow
374
        l.mul   r3, r4, r5
375
        l.nop   0x2
376
        CHECK_OV_CLEAR
377
 
378
        // Now multiply by 3 - should only just overflow
379
        l.mul   r3, r4, r6
380
        l.nop   0x2
381
        CHECK_OV_SET
382
 
383
        l.add   r3, r0, r0      ;// Should clear overflow
384
        l.nop   0x2
385
        CHECK_OV_CLEAR
386
 
387
        // First multiply big number by 2 - shouldn't overflow
388
        l.muli  r3, r4, 0x2
389
        l.nop   0x2
390
        CHECK_OV_CLEAR
391
 
392
        // Now multiply by 3 - should just overflow negative
393
        l.muli  r3, r4, 0x3
394
        l.nop   0x2
395
        CHECK_OV_SET
396
 
397
        l.add   r3, r0, r0      ;// Should clear overflow
398
        l.nop   0x2
399
        CHECK_OV_CLEAR
400
 
401
 
402
        // Now check overflow on  unsigned multiply
403
 
404
        // Some stimulus to make a 32-bit multiply overflow
405
        l.movhi r4, 0x5555      ;//((2^32))/3 + 2
406
        l.ori   r4, r4, 0x5557
407
        l.ori   r5, r0, 2
408
        l.ori   r6, r0, 3
409
 
410
        // First multiply big negative number by 2 - shouldn't overflow
411
        l.mulu  r3, r4, r5
412
        l.nop   0x2
413
        CHECK_OV_CLEAR
414
 
415
        // Now multiply by 3 - should just overflow negative
416
        l.mulu  r3, r4, r6
417
        l.nop   0x2
418
        CHECK_OV_SET
419
 
420
        l.add   r3, r0, r0      ;// Should clear overflow
421
        l.nop   0x2
422
        CHECK_OV_CLEAR
423
 
424
#endif
425
 
426
        /////////////////////////////////////////////////////////////
427
        //                                                         //
428
        // Range Exception Tests                                   //
429
        //                                                         //
430
        /////////////////////////////////////////////////////////////
431
#ifdef OR1200_IMPL_OVE
432
        // report indicator that we're at exception section 0xeeeeeeee
433
        l.movhi r3, 0xeeee
434
        l.ori   r3, r3, 0xeeee
435
        l.nop   0x2
436
 
437
        // First enable OV exception in SR
438
 
439
        l.mfspr r20, r0, SPR_SR
440
        l.ori   r21, r20, SPR_SR_OVE
441
        l.mtspr r0, r21, SPR_SR
442
 
443
        // Check it's set
444
        l.mfspr r20, r0, SPR_SR
445
        l.andi  r21, r20, SPR_SR_OVE
446
        l.sfnei r21, SPR_SR_OVE
447
        l.bf    _fail
448
        l.nop
449
 
450
        // now set r11 to r12 to know how many tests we've done so far
451
        l.or    r11, r12, r12
452
 
453
        l.movhi r4, 0x7fff
454
        l.ori   r4, r4, 0xefff
455
 
456
        l.ori   r5, r0, 0xffff
457
 
458
        l.add   r3, r5, r4      ;// Should set overflow
459
        l.nop   0x2
460
        EXPECT_RANGE_EXCEPT
461
 
462
        l.add   r3, r0, r0      ;// Should clear overflow
463
        l.nop   0x2
464
        CHECK_EXCEPTION_COUNTER
465
 
466
 
467
        l.addi  r3, r4, 0x7fff  ;// Should set overflow
468
        l.nop   0x2
469
        EXPECT_RANGE_EXCEPT
470
 
471
 
472
        l.add   r3, r0, r0      ;// Should clear overflow
473
        l.nop   0x2
474
        CHECK_EXCEPTION_COUNTER
475
 
476
 
477
        // Now test negative numbers
478
 
479
        l.movhi r4, 0x8000
480
        l.ori   r4, r4, 0x0000
481
 
482
        l.movhi r5, 0xffff
483
        l.ori   r5, r5, 0xffff
484
 
485
        l.add   r3, r4, r5      // Biggest and smallest negative number
486
        l.nop   0x2
487
        EXPECT_RANGE_EXCEPT
488
 
489
 
490
        l.add   r3, r0, r0      ;// Should clear overflow
491
        l.nop   0x2
492
        CHECK_EXCEPTION_COUNTER
493
 
494
        l.addi  r3, r4, 0xffff  // Biggest and smallest negative number
495
        l.nop   0x2
496
        EXPECT_RANGE_EXCEPT
497
 
498
 
499
        l.add   r3, r0, r0      ;// Should clear overflow
500
        l.nop   0x2
501
        CHECK_EXCEPTION_COUNTER
502
 
503
        l.add   r3, r4, r0      // Biggest negative number, and zero
504
        l.nop   0x2
505
        CHECK_EXCEPTION_COUNTER
506
 
507
 
508
        l.add   r3, r0, r0      ;// Should clear overflow
509
        l.nop   0x2
510
        CHECK_EXCEPTION_COUNTER
511
 
512
 
513
        l.movhi r5, 0xffff
514
        l.ori   r5, r5, 0xfffe
515
 
516
        l.add   r3, r4, r5      // Biggest and second smallest negative number
517
        l.nop   0x2
518
        EXPECT_RANGE_EXCEPT
519
 
520
 
521
        l.add   r3, r0, r0      ;// Should clear overflow
522
        l.nop   0x2
523
        CHECK_EXCEPTION_COUNTER
524
 
525
#ifdef OR1200_IMPL_SUB
526
 
527
        // report indicator that we're at l.sub section 0x55555555
528
        l.movhi r3, 0x5555
529
        l.ori   r3, r3, 0x5555
530
        l.nop   0x2
531
 
532
        // Quick subtract check
533
        // Check largest negative number -1 tripping overflow
534
        l.ori   r5, r0, 1               ; // +1
535
        l.sub   r3, r4, r5              ; // -2147483647 - 1
536
        l.nop   0x2
537
        EXPECT_RANGE_EXCEPT
538
 
539
 
540
        l.sub   r3, r0, r0      ;// Should clear overflow
541
        l.nop   0x2
542
        CHECK_EXCEPTION_COUNTER
543
 
544
#endif
545
 
546
        l.movhi r4, 0x8000
547
        l.ori   r4, r4, 0x0437
548
 
549
        l.movhi r5, 0xffff
550
        l.ori   r5, r5, 0xfbc7
551
 
552
        l.add   r3, r4, r5      // Very big negative number, another one big
553
                                // enough to cause overflow hopefully
554
        l.nop   0x2
555
        EXPECT_RANGE_EXCEPT
556
 
557
 
558
        l.add   r3, r0, r0      ;// Should clear overflow
559
        l.nop   0x2
560
        CHECK_EXCEPTION_COUNTER
561
 
562
        l.movhi r5, 0xffff
563
        l.ori   r5, r5, 0xfff7
564
 
565
        l.add   r3, r4, r5      // Two negative numbers but shouldn't overflow
566
        l.nop   0x2
567
        CHECK_EXCEPTION_COUNTER
568
 
569
#ifdef OR1200_DIV_IMPLEMENTED
570
 
571
        // report indicator that we're at l.div section 0xdddddddd
572
        l.movhi r3, 0xdddd
573
        l.ori   r3, r3, 0xdddd
574
        l.nop   0x2
575
 
576
        // Test divide by zero
577
        l.div   r3, r5, r0
578
        l.nop   0x2
579
 
580
        l.sfne  r3, r0          ;// Check result was 0
581
        l.bf    _fail
582
 
583
        EXPECT_RANGE_EXCEPT
584
 
585
 
586
        l.add   r3, r5, r0      ;// Should clear overflow
587
        l.nop   0x2
588
 
589
        CHECK_EXCEPTION_COUNTER
590
 
591
        // Test divide by zero
592
        l.divu  r3, r0, r0
593
        l.nop   0x2
594
        EXPECT_RANGE_EXCEPT
595
 
596
 
597
        l.sfne  r3, r0          ;// Check result was 0
598
        l.bf    _fail
599
 
600
        l.add   r3, r0, r0      ;// Should clear overflow
601
        l.nop   0x2
602
        CHECK_EXCEPTION_COUNTER
603
 
604
#endif
605
 
606
#ifdef OR1200_MULT_IMPLEMENTED
607
 
608
        // report indicator that we're at l.multiply section 0x11111111
609
        l.movhi r3, 0x1111
610
        l.ori   r3, r3, 0x1111
611
        l.nop   0x2
612
 
613
        // Check multiplying two large numbers, which will cause overflow,
614
        // trigger the flag appropriately
615
 
616
        // First signed multiply.
617
        l.movhi r4, 0xd555      ;//-(((2^32)-1)/3 + 2)
618
        l.ori   r4, r4, 0x5552
619
        l.ori   r5, r0, 2
620
        l.ori   r6, r0, 3
621
 
622
        // First multiply big negative number by 2 - shouldn't overflow
623
        l.mul   r3, r4, r5
624
        l.nop   0x2
625
        CHECK_EXCEPTION_COUNTER
626
 
627
        // Now multiply by 3 - should just overflow negative
628
        l.mul   r3, r4, r6
629
        l.nop   0x2
630
        EXPECT_RANGE_EXCEPT
631
 
632
        l.add   r3, r0, r0      ;// Should clear overflow
633
        l.nop   0x2
634
        CHECK_EXCEPTION_COUNTER
635
 
636
        // Now some big positive values
637
        l.movhi r4, 0x2aaa      ;//((2^32)-1)/3 + 2
638
        l.ori   r4, r4, 0xaaae
639
        l.ori   r5, r0, 2
640
        l.ori   r6, r0, 3
641
 
642
        // First multiply big number by 2 - shouldn't overflow
643
        l.mul   r3, r4, r5
644
        l.nop   0x2
645
        CHECK_EXCEPTION_COUNTER
646
 
647
        // Now multiply by 3 - should only just overflow
648
        l.mul   r3, r4, r6
649
        l.nop   0x2
650
        EXPECT_RANGE_EXCEPT
651
 
652
        l.add   r3, r0, r0      ;// Should clear overflow
653
        l.nop   0x2
654
        CHECK_EXCEPTION_COUNTER
655
 
656
        // First multiply big number by 2 - shouldn't overflow
657
        l.muli  r3, r4, 0x2
658
        l.nop   0x2
659
        CHECK_EXCEPTION_COUNTER
660
 
661
        // Now multiply by 3 - should just overflow negative
662
        l.muli  r3, r4, 0x3
663
        l.nop   0x2
664
        EXPECT_RANGE_EXCEPT
665
 
666
        l.add   r3, r0, r0      ;// Should clear overflow
667
        l.nop   0x2
668
        CHECK_EXCEPTION_COUNTER
669
 
670
 
671
        // Now check overflow on  unsigned multiply
672
 
673
        // Some stimulus to make a 32-bit multiply overflow
674
        l.movhi r4, 0x5555      ;//((2^32))/3 + 2
675
        l.ori   r4, r4, 0x5557
676
        l.ori   r5, r0, 2
677
        l.ori   r6, r0, 3
678
 
679
        // First multiply big negative number by 2 - shouldn't overflow
680
        l.mulu  r3, r4, r5
681
        l.nop   0x2
682
        CHECK_EXCEPTION_COUNTER
683
 
684
        // Now multiply by 3 - should just overflow negative
685
        l.mulu  r3, r4, r6
686
        l.nop   0x2
687
        EXPECT_RANGE_EXCEPT
688
 
689
        l.add   r3, r0, r0      ;// Should clear overflow
690
        l.nop   0x2
691
        CHECK_EXCEPTION_COUNTER
692
 
693
#endif
694
 
695
#endif
696
 
697
 
698
_finish:
699
        l.movhi r3, hi(0x8000000d)
700
        l.ori   r3, r3, lo(0x8000000d)
701
        l.nop   0x2
702
        l.ori   r3, r0, 0
703
        l.nop   0x1
704
 
705
_fail:
706
        l.or    r3, r12, r0     ;// Fail and report test number we were up to
707
        l.nop   0x1

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.