aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite/sh/ftrc.s
blob: 25e33be33ad41857efd4fc5501337bf6c77fac17 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# sh testcase for ftrc 
# mach: sh
# as(sh):	-defsym sim_cpu=0

	.include "testutils.inc"

	start
ftrc_single:
	set_grs_a5a5
	set_fprs_a5a5
	# ftrc(0.0) = 0.
	fldi0	fr0
	ftrc	fr0, fpul
	# check results.
	mov	#0, r0
	sts	fpul, r1
	cmp/eq	r0, r1
	bt	.L0
	fail
.L0:
	# ftrc(1.5) = 1.
	fldi1	fr0
	fldi1	fr1
	fldi1	fr2
	# double it.
	fadd	fr2, fr2
	# form the fraction.
	fdiv	fr2, fr1
	fadd	fr1, fr0
	# now we've got 1.5 in fr0.
	ftrc	fr0, fpul
	# check results.
	mov	#1, r0
	sts	fpul, r1
	cmp/eq	r0, r1
	bt	.L1
	fail
.L1:
	# ftrc(-1.5) = -1.
	fldi1	fr0
	fneg	fr0
	fldi1	fr1
	fldi1	fr2
	# double it.
	fadd	fr2, fr2
	# form the fraction.
	fdiv	fr2, fr1
	fneg	fr1
	# -1 + -0.5 = -1.5.
	fadd	fr1, fr0
	# now we've got 1.5 in fr0.
	ftrc	fr0, fpul
	# check results.
	mov	#1, r0
	neg	r0, r0
	sts	fpul, r1
	cmp/eq	r0, r1
	bt	ftrc_double
	fail

ftrc_double:
	double_prec
	# ftrc(0.0) = 0.
	fldi0	fr0
	_s2d	fr0, dr0
	ftrc	dr0, fpul
	# check results.
	mov	#0, r0
	sts	fpul, r1
	cmp/eq	r0, r1
	bt	.L10
	fail
.L10:
	# ftrc(1.5) = 1.
	fldi1	fr0
	fldi1	fr2
	fldi1	fr4
	# double it.
	single_prec
	fadd	fr4, fr4
	# form 0.5.
	fdiv	fr4, fr2
	fadd	fr2, fr0
	double_prec
	# now we've got 1.5 in fr0, so do some single->double
	# conversions and perform the ftrc.
	_s2d	fr0, dr0
	_s2d	fr2, dr2
	_s2d	fr4, dr4
	ftrc	dr0, fpul
	
	# check results.
	mov	#1, r0
	sts	fpul, r1
	cmp/eq	r0, r1
	bt	.L11
	fail
.L11:
	# ftrc(-1.5) = -1.
	fldi1	fr0
	fneg	fr0
	fldi1	fr2
	fldi1	fr4
	single_prec
	# double it.
	fadd	fr4, fr4
	# form the fraction.
	fdiv	fr4, fr2
	fneg	fr2
	# -1 + -0.5 = -1.5.
	fadd	fr2, fr0
	double_prec
	# now we've got 1.5 in fr0, so do some single->double
	# conversions and perform the ftrc.
	_s2d	fr0, dr0
	_s2d	fr2, dr2
	_s2d	fr4, dr4
	ftrc	dr0, fpul
	
	# check results.
	mov	#1, r0
	neg	r0, r0
	sts	fpul, r1
	cmp/eq	r0, r1
	bt	.L12
	fail
.L12:
	assertreg0	-1
	assertreg	-1, r1
	test_gr_a5a5	r2
	test_gr_a5a5	r3
	test_gr_a5a5	r4
	test_gr_a5a5	r5
	test_gr_a5a5	r6
	test_gr_a5a5	r7
	test_gr_a5a5	r8
	test_gr_a5a5	r9
	test_gr_a5a5	r10
	test_gr_a5a5	r11
	test_gr_a5a5	r12
	test_gr_a5a5	r13
	test_gr_a5a5	r14

	assert_dpreg_i	2, dr4
	test_fpr_a5a5	fr6
	test_fpr_a5a5	fr7
	test_fpr_a5a5	fr8
	test_fpr_a5a5	fr9
	test_fpr_a5a5	fr10
	test_fpr_a5a5	fr11
	test_fpr_a5a5	fr12
	test_fpr_a5a5	fr13
	test_fpr_a5a5	fr14
	test_fpr_a5a5	fr15
	pass
	exit 0