1 # frv testcase for sdiv $GRi,$GRj,$GRk
4 .include "../testutils.inc"
10 ; simple division 12 / 3
17 set_gr_limmed 0x0123,0x4567,gr3
18 set_gr_limmed 0xfedc,0xba98,gr1
22 ; Special case from the Arch Spec Vol 2
23 or_spr_immed 0x20,isr ; turn on isr.edem
25 set_gr_limmed 0x8000,0x0000,gr1
27 test_gr_limmed 0x7fff,0xffff,gr2
28 test_spr_bits 0x4,2,1,isr ; isr.aexc is set
30 and_spr_immed -33,isr ; turn off isr.edem
31 ; set up exception handler
33 and_spr_immed -4081,tbr ; clear tbr.tt
35 inc_gr_immed 0x170,gr17 ; address of exception handler
40 ; divide will cause overflow
43 set_gr_limmed 0x8000,0x0000,gr1
44 e1: sdiv gr1,gr3,gr2 ; overflow
46 test_gr_limmed 0x8000,0x0000,gr2; gr2 updated
50 set_gr_immed 0xdeadbeef,gr2
51 e2: sdiv gr1,gr0,gr2 ; divide by zero
52 test_gr_immed 2,gr15 ; handler called
53 test_gr_immed 0xdeadbeef,gr2 ; gr2 not updated.
57 ok1: ; exception handler for overflow
58 test_spr_bits 0x18,3,0x2,isr ; isr.dtt is set
59 test_spr_bits 0x0001,0,0x1,esr0 ; esr0 is valid
60 test_spr_bits 0x003e,1,0x13,esr0 ; esr0.ec is set
65 ok2: ; exception handler for divide by zero
66 test_spr_bits 0x18,3,0x3,isr ; isr.dtt is set
67 test_spr_bits 0x0001,0,0x1,esr0 ; esr0 is valid
68 test_spr_bits 0x003e,1,0x13,esr0 ; esr0.ec is set