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 530

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
#define SHOULD_BE_SET   l.bnf   _fail
68
#define SHOULDNT_BE_SET l.bf    _fail
69
 
70
#define MOVE_TO_R4R5_AND_REPORT(a,b)    \
71
        l.movhi r3,hi(a)        ;       \
72
        l.ori   r3,r3,lo(a)     ;       \
73
        l.nop   0x2             ;       \
74
        l.or    r4,r3,r3        ;       \
75
        l.movhi r3,hi(b)        ;       \
76
        l.ori   r3,r3,lo(b)     ;       \
77
        l.nop   0x2             ;       \
78
        l.or    r5,r3,r3
79
 
80
 
81
// Tests to check these values should be less than
82
#define SHOULD_BE_LESS_THAN_SIGNED(a,b) \
83
        MOVE_TO_R4R5_AND_REPORT(a,b) ;  \
84
        l.sfeq  r4,r5           ;       \
85
        SHOULDNT_BE_SET         ;       \
86
        l.sfne  r4,r5           ;       \
87
        SHOULD_BE_SET           ;       \
88
        l.sfgts r4,r5           ;       \
89
        SHOULDNT_BE_SET         ;       \
90
        l.sfges r4,r5           ;       \
91
        SHOULDNT_BE_SET         ;       \
92
        l.sfles r4,r5           ;       \
93
        SHOULD_BE_SET           ;       \
94
        l.sflts r4,r5           ;       \
95
        SHOULD_BE_SET
96
 
97
#define SHOULD_BE_GREATER_THAN_SIGNED(a,b)      \
98
        MOVE_TO_R4R5_AND_REPORT(a,b) ;  \
99
        l.sfeq  r4,r5           ;       \
100
        SHOULDNT_BE_SET         ;       \
101
        l.sfne  r4,r5           ;       \
102
        SHOULD_BE_SET           ;       \
103
        l.sfgts r4,r5           ;       \
104
        SHOULD_BE_SET           ;       \
105
        l.sfges r4,r5           ;       \
106
        SHOULD_BE_SET           ;       \
107
        l.sfles r4,r5           ;       \
108
        SHOULDNT_BE_SET         ;       \
109
        l.sflts r4,r5           ;       \
110
        SHOULDNT_BE_SET
111
 
112
#define SHOULD_BE_LESS_THAN_UNSIGNED(a,b)       \
113
        MOVE_TO_R4R5_AND_REPORT(a,b) ;  \
114
        l.sfeq  r4,r5           ;       \
115
        SHOULDNT_BE_SET         ;       \
116
        l.sfne  r4,r5           ;       \
117
        SHOULD_BE_SET           ;       \
118
        l.sfgtu r4,r5           ;       \
119
        SHOULDNT_BE_SET         ;       \
120
        l.sfgeu r4,r5           ;       \
121
        SHOULDNT_BE_SET         ;       \
122
        l.sfleu r4,r5           ;       \
123
        SHOULD_BE_SET           ;       \
124
        l.sfltu r4,r5           ;       \
125
        SHOULD_BE_SET
126
 
127
#define SHOULD_BE_GREATER_THAN_UNSIGNED(a,b)    \
128
        MOVE_TO_R4R5_AND_REPORT(a,b) ;  \
129
        l.sfeq  r4,r5           ;       \
130
        SHOULDNT_BE_SET         ;       \
131
        l.sfne  r4,r5           ;       \
132
        SHOULD_BE_SET           ;       \
133
        l.sfgtu r4,r5           ;       \
134
        SHOULD_BE_SET           ;       \
135
        l.sfgeu r4,r5           ;       \
136
        SHOULD_BE_SET           ;       \
137
        l.sfleu r4,r5           ;       \
138
        SHOULDNT_BE_SET         ;       \
139
        l.sfltu r4,r5           ;       \
140
        SHOULDNT_BE_SET
141
 
142
#define INT_MAX         2147483647      /*0x7fffffff*/
143
#define INT_MAX_MIN1    2147483646      /*0x7ffffffe*/
144
#define NEG_INT_MAX     -2147483648     /*0x80000000*/
145
#define NEG_INT_MAX_PL1 -2147483647     /*0x80000001*/
146
#define MIN1            -1              /*0xffffffff*/
147
 
148
#define UINT_MAX        4294967295      /*0xffffffff*/
149
#define UINT_MAX_MIN1   4294967294      /*0xfffffffe*/
150
 
151
 
152
        .global _start
153
_start:
154
        /* Signed tests */
155
        SHOULD_BE_LESS_THAN_SIGNED(0,1)
156
 
157
        SHOULD_BE_LESS_THAN_SIGNED(MIN1,0)
158
 
159
        SHOULD_BE_LESS_THAN_SIGNED(INT_MAX_MIN1,INT_MAX)
160
 
161
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,INT_MAX)
162
 
163
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,INT_MAX_MIN1)
164
 
165
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX_PL1,INT_MAX)
166
 
167
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX_PL1,INT_MAX_MIN1)
168
 
169
        SHOULD_BE_LESS_THAN_SIGNED(-7,-6)
170
 
171
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,NEG_INT_MAX_PL1)
172
 
173
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,MIN1)
174
 
175
        SHOULD_BE_LESS_THAN_SIGNED(NEG_INT_MAX,0)
176
 
177
 
178
        SHOULD_BE_GREATER_THAN_SIGNED(1,0)
179
 
180
        SHOULD_BE_GREATER_THAN_SIGNED(0,MIN1)
181
 
182
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX,INT_MAX_MIN1)
183
 
184
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX,NEG_INT_MAX)
185
 
186
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX_MIN1,NEG_INT_MAX)
187
 
188
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX,NEG_INT_MAX_PL1)
189
 
190
        SHOULD_BE_GREATER_THAN_SIGNED(INT_MAX_MIN1,NEG_INT_MAX_PL1)
191
 
192
        SHOULD_BE_GREATER_THAN_SIGNED(-6,-7)
193
 
194
        SHOULD_BE_GREATER_THAN_SIGNED(NEG_INT_MAX_PL1,NEG_INT_MAX)
195
 
196
        SHOULD_BE_GREATER_THAN_SIGNED(MIN1,NEG_INT_MAX)
197
 
198
        SHOULD_BE_GREATER_THAN_SIGNED(0,NEG_INT_MAX)
199
 
200
        /* Unsigned tests */
201
        SHOULD_BE_LESS_THAN_UNSIGNED(0,1)
202
 
203
        SHOULD_BE_LESS_THAN_UNSIGNED(UINT_MAX_MIN1,UINT_MAX)
204
 
205
        SHOULD_BE_GREATER_THAN_UNSIGNED(1,0)
206
 
207
        SHOULD_BE_GREATER_THAN_UNSIGNED(UINT_MAX,UINT_MAX_MIN1)
208
 
209
 
210
 
211
_finish:
212
        l.movhi r3, hi(0x8000000d)
213
        l.ori   r3, r3, lo(0x8000000d)
214
        l.nop   0x2
215
        l.ori   r3, r0, 0
216
        l.nop   0x1
217
 
218
_fail:
219
        l.ori r3, r0, 0x1
220
        l.nop 0x1
221
 

powered by: WebSVN 2.1.0

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