Initial import
[gdb.git] / sim / testsuite / sim / m32r / trap.cgs
blob59e136a01735a321b01a29abdbec1e9ee7b1bd80
1 # m32r testcase for trap #$uimm4
2 # mach(): m32r m32rx
4         .include "testutils.inc"
6         start
8         .global trap
9 trap:
11 ; Test 1: bbpsw = 0, bpsw = 1, psw = 0
13         ; bbsm = 0, bie = 0, bbcond = 0
14         mvi_h_gr r4, 0
15         mvtc r4, cr8
17         ; bsm = 1, bie = 1, bcond = 1, sm = 0, ie = 0, cond = 0
18         mvi_h_gr r4, 0xc100
19         mvtc r4, cr0
21         ; bbpc = 0
22         mvaddr_h_gr r4, 0
23         mvtc r4, bbpc
25         ; bpc = 42
26         mvaddr_h_gr r4, 42
27         mvtc r4, bpc
29         ; Copy trap2_handler to trap area of memory.
30         ld24 r0,#0x48 ; address of trap 2 handler
31         ld24 r1,#trap2_handler
32         ld r2,@r1
33         st r2,@r0
34         ; Set up return address.
35         ld24 r5,#trap2_ret1
37 trap_insn1:
38         trap #2
39         fail
41 trap2_ret1:
42         ; test bbsm = 1, bbie = 1, bbcond = 1
43         mvfc r4, cr8
44         test_h_gr r4, 0xc1
46         ; test bsm = 0, bie = 0, bcond = 0, sm = 0, ie = 0, cond = 0
47         mvfc r4, cr0
48         test_h_gr r4, 0
50         ; test bbpc = 42
51         mvfc r4, bbpc
52         test_h_gr r4, 42
54         ; test bpc = proper return address
55         mvfc r4, bpc
56         test_h_gr r4, trap_insn1 + 4
58 ; Test 2: bbpsw = 1, bpsw = 0, psw = 1
60         ; bbsm = 1, bie = 1, bbcond = 1
61         mvi_h_gr r4, 0xc1
62         mvtc r4, cr8
64         ; bsm = 0, bie = 0, bcond = 0, sm = 1, ie = 1, cond = 1
65         mvi_h_gr r4, 0xc1
66         mvtc r4, cr0
68         ; bbpc = 42
69         mvaddr_h_gr r4, 42
70         mvtc r4, bbpc
72         ; bpc = 0
73         mvaddr_h_gr r4, 0
74         mvtc r4, bpc
76         ; Set up return address.
77         ld24 r5,#trap2_ret2
79 trap_insn2:
80         trap #2
81         fail
83 trap2_ret2:
84         ; test bbsm = 0, bbie = 0, bbcond = 0
85         mvfc r4, cr8
86         test_h_gr r4, 0
88         ; test bsm = 1, bie = 1, bcond = 1, sm = 1, ie = 0, cond = 0
89         mvfc r4, cr0
90         test_h_gr r4, 0xc180
92         ; test bbpc = 0
93         mvfc r4, bbpc
94         test_h_gr r4, 0
96         ; test bpc = proper return address
97         mvfc r4, bpc
98         test_h_gr r4, trap_insn2 + 4
100         pass
102         .data
104 ; Don't use rte as it will undo the effects of trap we're testing.
106         .p2align 2
107 trap2_handler:
108         jmp r5
109         nop