1# Blackfin testcase for link/unlink instructions
2# mach: bfin
3
4	.include "testutils.inc"
5
6	start
7
8	/* give FP/RETS known/different values */
9	R7.H = 0xdead;
10	R7.L = 0x1234;
11	RETS = R7;
12	R6 = R7;
13	R6 += 0x23;
14	FP = R6;
15
16	/* SP should have moved by -8 bytes (to push FP/RETS) */
17	R0 = SP;
18	LINK 0;
19	R1 = SP;
20	R1 += 8;
21	CC = R0 == R1;
22	IF !CC JUMP 1f;
23
24	/* FP should now have the same value as SP */
25	R1 = SP;
26	R2 = FP;
27	CC = R1 == R2;
28	IF !CC JUMP 1f;
29
30	/* make sure FP/RETS on the stack have our known values */
31	R1 = [SP];
32	CC = R1 == R6;
33	IF !CC JUMP 1f;
34
35	R1 = [SP + 4];
36	CC = R1 == R7;
37	IF !CC JUMP 1f;
38
39	/* UNLINK should:
40	 *	assign SP to current FP
41	 *	adjust SP by -8 bytes
42	 *	restore RETS/FP from the stack
43	 */
44	R4 = 0;
45	RETS = R4;
46	R0 = SP;
47	UNLINK;
48
49	/* Check new SP */
50	R1 = SP;
51	R1 += -0x8;
52	CC = R1 == R0;
53	IF !CC JUMP 1f;
54
55	/* Check restored RETS */
56	R1 = RETS;
57	CC = R1 == R7;
58	IF !CC JUMP 1f;
59
60	/* Check restored FP */
61	R1 = FP;
62	CC = R1 == R6;
63	IF !CC JUMP 1f;
64
65	pass
661:
67	fail
68