OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-sf.S] - Blame information for rev 746

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 504 julius
/*
2
 
3
        Basic l.sfxx comparison instruction tests.
4
 
5
        Does not cover set-flag-against-immediate
6
 
7
        Julius Baxter, ORSoC AB, 
8
 
9
*/
10
//////////////////////////////////////////////////////////////////////
11
////                                                              ////
12
//// Copyright (C) 2011 Authors and OPENCORES.ORG                 ////
13
////                                                              ////
14
//// This source file may be used and distributed without         ////
15
//// restriction provided that this copyright statement is not    ////
16
//// removed from the file and that any derivative work contains  ////
17
//// the original copyright notice and the associated disclaimer. ////
18
////                                                              ////
19
//// This source file is free software; you can redistribute it   ////
20
//// and/or modify it under the terms of the GNU Lesser General   ////
21
//// Public License as published by the Free Software Foundation; ////
22
//// either version 2.1 of the License, or (at your option) any   ////
23
//// later version.                                               ////
24
////                                                              ////
25
//// This source is distributed in the hope that it will be       ////
26
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
27
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
28
//// PURPOSE.  See the GNU Lesser General Public License for more ////
29
//// details.                                                     ////
30
////                                                              ////
31
//// You should have received a copy of the GNU Lesser General    ////
32
//// Public License along with this source; if not, download it   ////
33
//// from http://www.opencores.org/lgpl.shtml                     ////
34
////                                                              ////
35
//////////////////////////////////////////////////////////////////////
36
 
37
 
38
#include "spr-defs.h"
39
 
40
 
41
/* =================================================== [ exceptions ] === */
42
        .section .vectors, "ax"
43
 
44
 
45
/* ---[ 0x100: RESET exception ]----------------------------------------- */
46
        .org 0x100
47
        l.movhi r0, 0
48
        /* Clear status register */
49
        l.ori r1, r0, SPR_SR_SM
50
        l.mtspr r0, r1, SPR_SR
51
        /* Clear timer  */
52
        l.mtspr r0, r0, SPR_TTMR
53
 
54
        /* Jump to program initialisation code */
55
        .global _start
56
        l.movhi r4, hi(_start)
57
        l.ori r4, r4, lo(_start)
58
        l.jr    r4
59
        l.nop
60
 
61
 
62
/* =================================================== [ text ] === */
63
        .section .text
64
 
65
/* =================================================== [ start ] === */
66
 
67 619 julius
#define SHOULD_BE_SET   l.bnf   _fail ; \
68
        l.nop 0
69
#define SHOULDNT_BE_SET l.bf    _fail ; \
70
        l.nop 0
71 504 julius
 
72
#define MOVE_TO_R4R5_AND_REPORT(a,b)    \
73
        l.movhi r3,hi(a)        ;       \
74
        l.ori   r3,r3,lo(a)     ;       \
75
        l.nop   0x2             ;       \
76
        l.or    r4,r3,r3        ;       \
77
        l.movhi r3,hi(b)        ;       \
78
        l.ori   r3,r3,lo(b)     ;       \
79
        l.nop   0x2             ;       \
80
        l.or    r5,r3,r3
81
 
82
 
83
// Tests to check these values should be less than
84
#define SHOULD_BE_LESS_THAN_SIGNED(a,b) \
85
        MOVE_TO_R4R5_AND_REPORT(a,b) ;  \
86
        l.sfeq  r4,r5           ;       \
87
        SHOULDNT_BE_SET         ;       \
88
        l.sfne  r4,r5           ;       \
89
        SHOULD_BE_SET           ;       \
90
        l.sfgts r4,r5           ;       \
91
        SHOULDNT_BE_SET         ;       \
92
        l.sfges r4,r5           ;       \
93
        SHOULDNT_BE_SET         ;       \
94
        l.sfles r4,r5           ;       \
95
        SHOULD_BE_SET           ;       \
96
        l.sflts r4,r5           ;       \
97
        SHOULD_BE_SET
98
 
99
#define SHOULD_BE_GREATER_THAN_SIGNED(a,b)      \
100
        MOVE_TO_R4R5_AND_REPORT(a,b) ;  \
101
        l.sfeq  r4,r5           ;       \
102
        SHOULDNT_BE_SET         ;       \
103
        l.sfne  r4,r5           ;       \
104
        SHOULD_BE_SET           ;       \
105
        l.sfgts r4,r5           ;       \
106
        SHOULD_BE_SET           ;       \
107
        l.sfges r4,r5           ;       \
108
        SHOULD_BE_SET           ;       \
109
        l.sfles r4,r5           ;       \
110
        SHOULDNT_BE_SET         ;       \
111
        l.sflts r4,r5           ;       \
112
        SHOULDNT_BE_SET
113
 
114
#define SHOULD_BE_LESS_THAN_UNSIGNED(a,b)       \
115
        MOVE_TO_R4R5_AND_REPORT(a,b) ;  \
116
        l.sfeq  r4,r5           ;       \
117
        SHOULDNT_BE_SET         ;       \
118
        l.sfne  r4,r5           ;       \
119
        SHOULD_BE_SET           ;       \
120
        l.sfgtu r4,r5           ;       \
121
        SHOULDNT_BE_SET         ;       \
122
        l.sfgeu r4,r5           ;       \
123
        SHOULDNT_BE_SET         ;       \
124
        l.sfleu r4,r5           ;       \
125
        SHOULD_BE_SET           ;       \
126
        l.sfltu r4,r5           ;       \
127
        SHOULD_BE_SET
128
 
129
#define SHOULD_BE_GREATER_THAN_UNSIGNED(a,b)    \
130
        MOVE_TO_R4R5_AND_REPORT(a,b) ;  \
131
        l.sfeq  r4,r5           ;       \
132
        SHOULDNT_BE_SET         ;       \
133
        l.sfne  r4,r5           ;       \
134
        SHOULD_BE_SET           ;       \
135
        l.sfgtu r4,r5           ;       \
136
        SHOULD_BE_SET           ;       \
137
        l.sfgeu r4,r5           ;       \
138
        SHOULD_BE_SET           ;       \
139
        l.sfleu r4,r5           ;       \
140
        SHOULDNT_BE_SET         ;       \
141
        l.sfltu r4,r5           ;       \
142
        SHOULDNT_BE_SET
143
 
144
#define INT_MAX         2147483647      /*0x7fffffff*/
145
#define INT_MAX_MIN1    2147483646      /*0x7ffffffe*/
146
#define NEG_INT_MAX     -2147483648     /*0x80000000*/
147
#define NEG_INT_MAX_PL1 -2147483647     /*0x80000001*/
148
#define MIN1            -1              /*0xffffffff*/
149
 
150
#define UINT_MAX        4294967295      /*0xffffffff*/
151
#define UINT_MAX_MIN1   4294967294      /*0xfffffffe*/
152
 
153
 
154
        .global _start
155
_start:
156
        /* Signed tests */
157
        SHOULD_BE_LESS_THAN_SIGNED(0,1)
158
 
159
        SHOULD_BE_LESS_THAN_SIGNED(MIN1,0)
160
 
161
        SHOULD_BE_LESS_THAN_SIGNED(INT_MAX_MIN1,INT_MAX)
162
 
163
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,INT_MAX)
164
 
165
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,INT_MAX_MIN1)
166
 
167
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX_PL1,INT_MAX)
168
 
169
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX_PL1,INT_MAX_MIN1)
170
 
171
        SHOULD_BE_LESS_THAN_SIGNED(-7,-6)
172
 
173
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,NEG_INT_MAX_PL1)
174
 
175
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,MIN1)
176
 
177
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,0)
178
 
179
 
180
        SHOULD_BE_GREATER_THAN_SIGNED(1,0)
181
 
182
        SHOULD_BE_GREATER_THAN_SIGNED(0,MIN1)
183
 
184
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX,INT_MAX_MIN1)
185
 
186
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX,NEG_INT_MAX)
187
 
188
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX_MIN1,NEG_INT_MAX)
189
 
190
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX,NEG_INT_MAX_PL1)
191
 
192
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX_MIN1,NEG_INT_MAX_PL1)
193
 
194
        SHOULD_BE_GREATER_THAN_SIGNED(-6,-7)
195
 
196
        SHOULD_BE_GREATER_THAN_SIGNED(NEG_INT_MAX_PL1,NEG_INT_MAX)
197
 
198
        SHOULD_BE_GREATER_THAN_SIGNED(MIN1,NEG_INT_MAX)
199
 
200
        SHOULD_BE_GREATER_THAN_SIGNED(0,NEG_INT_MAX)
201
 
202
        /* Unsigned tests */
203
        SHOULD_BE_LESS_THAN_UNSIGNED(0,1)
204
 
205
        SHOULD_BE_LESS_THAN_UNSIGNED(UINT_MAX_MIN1,UINT_MAX)
206
 
207
        SHOULD_BE_GREATER_THAN_UNSIGNED(1,0)
208
 
209
        SHOULD_BE_GREATER_THAN_UNSIGNED(UINT_MAX,UINT_MAX_MIN1)
210
 
211 619 julius
        SHOULD_BE_GREATER_THAN_UNSIGNED(UINT_MAX,0)
212 504 julius
 
213 619 julius
        SHOULD_BE_GREATER_THAN_UNSIGNED(0x80000001, 0x80000000)
214 504 julius
 
215 619 julius
        SHOULD_BE_LESS_THAN_UNSIGNED(0x80000000, 0x80000001)
216
 
217
        SHOULD_BE_GREATER_THAN_UNSIGNED(0x80000000,0x7fffffff)
218
 
219
        SHOULD_BE_LESS_THAN_UNSIGNED(0x7fffffff, 0x80000000)
220
 
221
        SHOULD_BE_GREATER_THAN_UNSIGNED(0x7fffffff, 0x7ffffffe)
222
 
223
        SHOULD_BE_LESS_THAN_UNSIGNED(0x7ffffffe, 0x7fffffff)
224
 
225 672 julius
        SHOULD_BE_LESS_THAN_UNSIGNED(0x2024fae0, 0xfef03220)
226
 
227 504 julius
_finish:
228
        l.movhi r3, hi(0x8000000d)
229
        l.ori   r3, r3, lo(0x8000000d)
230
        l.nop   0x2
231
        l.ori   r3, r0, 0
232
        l.nop   0x1
233
 
234
_fail:
235
        l.ori r3, r0, 0x1
236
        l.nop 0x1
237 672 julius
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.