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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [bench/] [asm/] [testdiv.S] - Blame information for rev 50

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

Line No. Rev Author Line
1 50 dgisselq
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;
3
; Filename:     testdiv.S
4
;
5
; Project:      Zip CPU -- a small, lightweight, RISC CPU soft core
6
;
7
; Purpose:      Tests the libraries signed division algorithm.
8
;
9
; Creator:      Dan Gisselquist, Ph.D.
10
;               Gisselquist Tecnology, LLC
11
;
12
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13
;
14
; Copyright (C) 2015, Gisselquist Technology, LLC
15
;
16
; This program is free software (firmware): you can redistribute it and/or
17
; modify it under the terms of  the GNU General Public License as published
18
; by the Free Software Foundation, either version 3 of the License, or (at
19
; your option) any later version.
20
;
21
; This program is distributed in the hope that it will be useful, but WITHOUT
22
; ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
23
; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
; for more details.
25
;
26
; License:      GPL, v3, as defined and found on www.gnu.org,
27
;               http://www.gnu.org/licenses/gpl.html
28
;
29
;
30
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31
;
32
; Registers:
33
;       R12     Peripheral base
34
;       R11     Address of our one memory variable
35
;
36
#include "sys.i"
37
start:
38
        LDI     0xc0000000,R12  ; Get the address of our peripheral base
39
        MOV     $1(PC),R11      ; Get a memory address for a variable
40
        BRA     skip_test_variable
41
test_variable:
42
        .DAT    0
43
skip_test_variable:
44
        LDI     $-1,R0  ; Start the watchdog timer
45
        STO     R0,sys.bus.wdt(R12)
46
        LSR     $1,R0   ; R0 now = 0x7fffffff
47
        STO     R0,sys.bus.tma(R12)
48
        LSR     $1,R0   ; R0 now = 0x3fffffff
49
        STO     R0,sys.bus.tmb(R12)
50
        LSR     $1,R0
51
        STO     R0,sys.bus.tmc(R12)
52
        ;
53
        CLR     R0
54
wdt_test_loop:
55
        ADD     $1,R0
56
        LOD     (R11),R1
57
        CMP     R0,R1
58
        STO.LT  R0,(R11)
59
        TST     -1,R0
60
        BLT     wdt_test_program_is_broken
61
        BRA     wdt_test_loop
62
 
63
wdt_test_program_is_broken:
64
        HALT
65
 
66
 
67
 
68
 
69
 
70
 
71
 
72
 
73
 
74
 
75 41 dgisselq
entry:
76
        ; Set up a test program
77
        MOV     test_div_program(PC),uPC
78
        MOV     top_of_stack(PC),uSP
79
        ; Run it in user space
80
        RTU
81
        ; Check for how the result came back: R0 = 0 means success
82
        MOV     uR11,R11
83
        TST     -1,R11
84
        HALT.Z
85
        BUSY
86
 
87
test_div_program:
88
        SUB     1,SP
89
        ;
90
        LDI     1,R11
91
        LDI     5,R0
92
        LDI     1,R1
93
        LDI     5,R2
94
        LDI     0,R3
95
        MOV     __HERE__+3(PC),R4
96
        STO     R4,1(SP)
97
        BRA     test_divs
98
 
99
        ;
100
        LDI     2,R11
101
        LDI     5,R0
102
        LDI     2,R1
103
        LDI     2,R2
104
        LDI     1,R3
105
        MOV     __HERE__+3(PC),R4
106
        STO     R4,1(SP)
107
        BRA     test_divs
108
 
109
        ;
110
        LDI     3,R11
111
        LDI     0xb53d0,R0
112
        LDI     0x2d,R1
113
        LDI     16496,R2
114
        LDI     32,R3
115
        MOV     __HERE__+3(PC),R4
116
        STO     R4,1(SP)
117
        BRA     test_divs
118
 
119
        ;
120
        LDI     4,R11
121
        LDI     2031890191,R0
122
        LDI     120193795,R1
123
        LDI     16,R2
124
        LDI     108789471,R3
125
        MOV     __HERE__+3(PC),R4
126
        STO     R4,1(SP)
127
        BRA     test_divs
128
 
129
        ;
130
        LDI     5,R11
131
        LDI     203553,R0
132
        LDI     142580994,R1
133
        LDI     0,R2
134
        LDI     203553,R3
135
        MOV     __HERE__+3(PC),R4
136
        STO     R4,1(SP)
137
        BRA     test_divs
138
 
139
        ;
140
        LDI     6,R11
141
        LDI     142580994,R0
142
        LDI     203553,R1
143
        LDI     700,R2
144
        LDI     93894,R3
145
        MOV     __HERE__+3(PC),R4
146
        STO     R4,1(SP)
147
        BRA     test_divs
148
 
149
        ;
150
        LDI     7,R11
151
        LDI     142580994,R0
152
        LDI     2499,R1
153
        LDI     57055,R2
154
        LDI     549,R3
155
        MOV     __HERE__+3(PC),R4
156
        STO     R4,1(SP)
157
        BRA     test_divs
158
 
159
        ;
160
        LDI     8,R11
161
        LDI     -142580994,R0
162
        LDI     2499,R1
163
        LDI     -57055,R2
164
        LDI     -549,R3
165
        MOV     __HERE__+3(PC),R4
166
        STO     R4,1(SP)
167
        BRA     test_divs
168
 
169
        ;
170
        LDI     9,R11
171
        LDI     142580994,R0
172
        LDI     -2499,R1
173
        LDI     -57055,R2
174
        LDI     549,R3
175
        MOV     __HERE__+3(PC),R4
176
        STO     R4,1(SP)
177
        BRA     test_divs
178
 
179
        ;
180
        LDI     10,R11
181
        LDI     -142580994,R0
182
        LDI     -2499,R1
183
        LDI     57055,R2
184
        LDI     -549,R3
185
        MOV     __HERE__+3(PC),R4
186
        STO     R4,1(SP)
187
        BRA     test_divs
188
 
189
        ;
190
        CLR     R11
191
        TRAP    0
192
 
193
test_divs:
194
        ;       R0 = Numerator
195
        ;       R1 = Denominator
196
        ;       R2 = Integer result
197
        ;       R3 = Remainder
198
        ;       R11= Test failure ID
199
        SUB     1,SP
200
        MOV     R2,R4
201
        MOV     R3,R5
202
        MOV     __HERE__+3(PC),R2
203
        STO     R2,1(SP)
204
        BRA     divs
205
        CMP     R0,R4
206
        BNZ     test_failure
207
        CMP     R1,R5
208
        BNZ     test_failure
209
        ADD     1,SP
210
        RETN
211
 
212
test_failure:
213
        TRAP    0
214
        NOOP
215
        BUSY
216
 

powered by: WebSVN 2.1.0

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