1# Blackfin testcase for USP handling
2# mach: bfin
3# sim: --environment operating
4
5#include "test.h"
6	.include "testutils.inc"
7
8	start
9
10	imm32 R5, 0x44455566
11	imm32 R6, 0x12345678
12	imm32 R7, 0x9abcdef0
13
14	imm32 p0, EVT3;
15	loadsym r0, exception;
16	[p0] = r0;
17
18	loadsym r0, usermode;
19	reti = r0;
20
21	SP = R6;
22	USP = R7;
23	RTI;
24
25usermode:
26	# SP should now be USP
27	R1 = SP;
28	CC = R1 == R7;
29	IF !CC JUMP fail;
30
31	# Now set SP to another value
32	SP = R5;
33
34	# Move up to exception space
35	EXCPT 0;
36
37exception:
38	# SP should be the same as original, but USP should change
39	R1 = SP;
40	CC = R1 == R6;
41	IF !CC JUMP fail;
42
43	R1 = USP;
44	CC = R1 == R5;
45	IF !CC JUMP fail;
46
47	dbg_pass
48
49fail:
50	dbg_fail
51