aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite/bfin/link.s
blob: c92ae1bb00d4358e3609f2e067fe2e88199bdea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Blackfin testcase for link/unlink instructions
# mach: bfin

	.include "testutils.inc"

	start

	/* give FP/RETS known/different values */
	R7.H = 0xdead;
	R7.L = 0x1234;
	RETS = R7;
	R6 = R7;
	R6 += 0x23;
	FP = R6;

	/* SP should have moved by -8 bytes (to push FP/RETS) */
	R0 = SP;
	LINK 0;
	R1 = SP;
	R1 += 8;
	CC = R0 == R1;
	IF !CC JUMP 1f;

	/* FP should now have the same value as SP */
	R1 = SP;
	R2 = FP;
	CC = R1 == R2;
	IF !CC JUMP 1f;

	/* make sure FP/RETS on the stack have our known values */
	R1 = [SP];
	CC = R1 == R6;
	IF !CC JUMP 1f;

	R1 = [SP + 4];
	CC = R1 == R7;
	IF !CC JUMP 1f;

	/* UNLINK should:
	 *	assign SP to current FP
	 *	adjust SP by -8 bytes
	 *	restore RETS/FP from the stack
	 */
	R4 = 0;
	RETS = R4;
	R0 = SP;
	UNLINK;

	/* Check new SP */
	R1 = SP;
	R1 += -0x8;
	CC = R1 == R0;
	IF !CC JUMP 1f;

	/* Check restored RETS */
	R1 = RETS;
	CC = R1 == R7;
	IF !CC JUMP 1f;

	/* Check restored FP */
	R1 = FP;
	CC = R1 == R6;
	IF !CC JUMP 1f;

	pass
1:
	fail