Home | History | Annotate | Line # | Download | only in fr400
      1  1.1  christos # frv testcase for sdivi $GRi,$s12,$GRk
      2  1.1  christos # mach: all
      3  1.1  christos 
      4  1.1  christos 	.include "../testutils.inc"
      5  1.1  christos 
      6  1.1  christos 	start
      7  1.1  christos 
      8  1.1  christos 	.global sdivi
      9  1.1  christos sdivi:
     10  1.1  christos 	; simple division 12 / 3
     11  1.1  christos 	set_gr_immed   	12,gr1
     12  1.1  christos 	sdivi      	gr1,3,gr2
     13  1.1  christos 	test_gr_immed  	4,gr2
     14  1.1  christos 
     15  1.1  christos 	; Random example
     16  1.1  christos 	set_gr_limmed  	0xfedc,0xba98,gr1
     17  1.1  christos 	sdivi      	gr1,0x7ff,gr2
     18  1.1  christos 	test_gr_limmed 	0xffff,0xdb93,gr2
     19  1.1  christos 
     20  1.1  christos 	; Random negative example
     21  1.1  christos 	set_gr_limmed  	0xfedc,0xba98,gr1
     22  1.1  christos 	sdivi      	gr1,-2048,gr2
     23  1.1  christos 	test_gr_immed 	0x2468,gr2
     24  1.1  christos 
     25  1.1  christos 	; Special case from the Arch Spec Vol 2
     26  1.1  christos 	or_spr_immed	0x20,isr	; turn on isr.edem
     27  1.1  christos 	set_gr_limmed  	0x8000,0x0000,gr1
     28  1.1  christos 	sdivi      	gr1,-1,gr2
     29  1.1  christos 	test_gr_limmed 	0x7fff,0xffff,gr2
     30  1.1  christos 	test_spr_bits	0x4,2,1,isr	; isr.aexc is set
     31  1.1  christos 
     32  1.1  christos 	and_spr_immed	-33,isr		; turn off isr.edem
     33  1.1  christos 	; set up exception handler
     34  1.1  christos 	set_psr_et	1
     35  1.1  christos 	and_spr_immed	-4081,tbr	; clear tbr.tt
     36  1.1  christos 	set_gr_spr	tbr,gr17
     37  1.1  christos 	inc_gr_immed	0x170,gr17	; address of exception handler
     38  1.1  christos 	set_bctrlr_0_0  gr17
     39  1.1  christos 	set_spr_immed	128,lcr
     40  1.1  christos 	set_gr_immed	0,gr15
     41  1.1  christos 
     42  1.1  christos 	; divide will cause overflow
     43  1.1  christos 	set_spr_addr	ok1,lr
     44  1.1  christos 	set_gr_limmed  	0x8000,0x0000,gr1
     45  1.1  christos e1:	sdivi      	gr1,-1,gr2
     46  1.1  christos 	test_gr_immed	1,gr15
     47  1.1  christos 	test_gr_limmed 	0x8000,0x0000,gr2
     48  1.1  christos 
     49  1.1  christos 	; divide by zero
     50  1.1  christos 	set_spr_addr	ok2,lr
     51  1.1  christos e2:	sdivi      	gr1,0,gr2	; divide by zero
     52  1.1  christos 	test_gr_immed	2,gr15
     53  1.1  christos 
     54  1.1  christos 	pass
     55  1.1  christos 
     56  1.1  christos ok1:	; exception handler for overflow
     57  1.1  christos 	test_spr_bits	0x18,3,0x2,isr		; isr.dtt is set
     58  1.1  christos 	test_spr_bits	0x0001,0,0x1,esr0	; esr0 is valid
     59  1.1  christos 	test_spr_bits	0x003e,1,0x13,esr0	; esr0.ec is set
     60  1.1  christos 	inc_gr_immed	1,gr15
     61  1.1  christos 	rett		0
     62  1.1  christos 	fail
     63  1.1  christos 
     64  1.1  christos ok2:	; exception handler for divide by zero
     65  1.1  christos 	test_spr_bits	0x18,3,0x3,isr		; isr.dtt is set
     66  1.1  christos 	test_spr_bits	0x0001,0,0x1,esr0	; esr0 is valid
     67  1.1  christos 	test_spr_bits	0x003e,1,0x13,esr0	; esr0.ec is set
     68  1.1  christos 	inc_gr_immed	1,gr15
     69  1.1  christos 	rett		0
     70  1.1  christos 	fail
     71