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

Subversion Repositories minirisc

[/] [minirisc/] [trunk/] [scode/] [sanity2.asm] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 lampret
;/////////////////////////////////////////////////////////////////////
2
;////                                                             ////
3
;////  Mini-RISC-1                                                ////
4
;////  Compliance Test 2                                          ////
5
;////  Tests PLC register Rd/Wr                                   ////
6
;////                                                             ////
7
;////  Author: Rudolf Usselmann                                   ////
8
;////          russelmann@hotmail.com                             ////
9
;////                                                             ////
10
;/////////////////////////////////////////////////////////////////////
11
;////                                                             ////
12
;//// Copyright (C) 2000 Rudolf Usselmann                         ////
13
;////                    russelmann@hotmail.com                   ////
14
;////                                                             ////
15
;//// This source file may be used and distributed without        ////
16
;//// restriction provided that this copyright statement is not   ////
17
;//// removed from the file and that any derivative work contains ////
18
;//// the original copyright notice and the associated disclaimer.////
19
;////                                                             ////
20
;//// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY        ////
21
;//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT           ////
22
;//// LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND   ////
23
;//// FITNESS FOR A PARTICULAR PURPOSE.                           ////
24
;////                                                             ////
25
;/////////////////////////////////////////////////////////////////////
26
 
27
        list    p=16c57
28
        #include p16c5x.inc
29
 
30
; global Registers
31
r0      equ     0x8
32
r1      equ     0x9
33
r2      equ     0xa
34
r3      equ     0xb
35
r4      equ     0xc
36
r5      equ     0xd
37
r6      equ     0xe
38
r7      equ     0xf
39
 
40
; banked Registers
41
br0     equ     0x10
42
br1     equ     0x11
43
br2     equ     0x12
44
br3     equ     0x13
45
br4     equ     0x14
46
br5     equ     0x15
47
br6     equ     0x16
48
br7     equ     0x17
49
br8     equ     0x18
50
br9     equ     0x19
51
br10    equ     0x1a
52
br11    equ     0x1b
53
br12    equ     0x1c
54
br13    equ     0x1d
55
br14    equ     0x1e
56
br15    equ     0x1f
57
 
58
 
59
;       PORTB Indicates Test Number
60
;       PORTA Indicates Status: 0 - Running; 1 - done OK; ff - stoped on error
61
 
62
main    ; Main code entry
63
        ; Port IO Test
64
        ; All ports have a Pull up resistor
65
 
66
        ; SETUP all ports
67
        clrw
68
        movwf   FSR
69
        movwf   PORTA
70
        movwf   PORTB
71
        movwf   PORTC
72
        tris    PORTA
73
        tris    PORTB
74
        tris    PORTC
75
 
76
        ; -------------------------------
77
        ; ---- Test the PLC register ----
78
        ; -------------------------------
79
 
80
        ; PLC read test 1       TEST 0
81
 
82
        movlw   pclrd1
83
        movwf   r0
84
        movf    PCL,W
85
pclrd1  subwf   r0,W
86
        btfss   STATUS,Z
87
        goto    lerr
88
 
89
        ; PLC read test 2       TEST 1
90
        movlw   0x01
91
        movwf   PORTB   ; Set Test Number
92
 
93
        movlw   pclrd2
94
        movwf   r3
95
        movf    PCL,W
96
pclrd2  subwf   r3,W
97
        btfss   STATUS,Z
98
        goto    lerr
99
 
100
        ; PLC write test 2      TEST 2
101
        movlw   0x02
102
        movwf   PORTB   ; Set Test Number
103
 
104
        movlw   pclwr1
105
        movwf   PCL
106
 
107
        goto    lerr
108
        goto    lerr
109
        goto    lerr
110
pclwr1  goto    pcl1
111
        goto    lerr
112
        goto    lerr
113
        goto    lerr
114
 
115
pcl1
116
        ; PLC write test 2      TEST 3
117
        movlw   0x03
118
        movwf   PORTB   ; Set Test Number
119
 
120
        movlw   pclwr2
121
        movwf   PCL
122
 
123
        goto    lerr
124
        goto    lerr
125
        goto    lerr
126
pclwr2  goto    pcl2
127
        goto    lerr
128
        goto    lerr
129
        goto    lerr
130
 
131
pcl2    ; Test other instructions that modify PC
132
        ; This are ADDWF PC, BSF PC,X and BCF PC,X
133
        ; (movwf pc already tested above)
134
 
135
        ; PLC write test 3      TEST 4
136
        ; test addwf PC
137
        movlw   0x04
138
        movwf   PORTB   ; Set Test Number
139
 
140
        movlw   pcl3b
141
        movwf   r0
142
        movlw   pcl3a
143
        subwf   r0,W
144
pcl3a   addwf   PCL,1
145
 
146
        goto    lerr
147
        goto    lerr
148
pcl3b   goto    lerr
149
        goto    pcl3c
150
        goto    lerr
151
        goto    lerr
152
        goto    lerr
153
pcl3c
154
 
155
        ; PLC write test 4      TEST 5
156
        ; test addwf PC
157
        movlw   0x05
158
        movwf   PORTB   ; Set Test Number
159
 
160
        movlw   pcl4b
161
        movwf   br8
162
        movlw   pcl4a
163
        subwf   br8,W
164
pcl4a   addwf   PCL,1
165
 
166
        goto    lerr
167
        goto    lerr
168
pcl4b   goto    lerr
169
        goto    pcl4c
170
        goto    lerr
171
        goto    lerr
172
        goto    lerr
173
pcl4c
174
 
175
        ; PLC write test 5      TEST 6
176
        ; test bsf PC,N
177
        movlw   0x06
178
        movwf   PORTB   ; Set Test N
179
 
180
; allign memory
181
        goto    pcl50
182
 
183
pcl50   org     0x60
184
 
185
        bsf     PCL,1   ; 60
186
        goto    lerr    ; 61
187
        goto    lerr    ; 62
188
        goto    pcl5a   ; 63
189
        goto    lerr    ; 64
190
        goto    lerr    ; 65
191
        goto    lerr    ; 66
192
        goto    lerr    ; 67
193
 
194
pcl5a
195
 
196
        ; PLC write test 6      TEST 7
197
        ; test bsf PC,N
198
        movlw   0x07
199
        movwf   PORTB   ; Set Test N
200
 
201
        bsf     PCL,2   ; 6A
202
        goto    lerr    ; 6B
203
        goto    lerr    ; 6C
204
        goto    lerr    ; 6D
205
        goto    lerr    ; 6E
206
        goto    pcl6a   ; 6F
207
        goto    lerr    ; 70
208
        goto    lerr    ; 71
209
 
210
pcl6a
211
 
212
        ; PLC write test 7      TEST 8
213
        ; test bcf PC,N
214
        movlw   0x08
215
        movwf   PORTB   ; Set Test N
216
 
217
        goto    pcl7a   ; 74
218
        goto    lerr    ; 75
219
        goto    lerr    ; 76
220
        goto    lerr    ; 77
221
        goto    lerr    ; 78
222
        goto    pcl7b   ; 79
223
        goto    lerr    ; 7a
224
        goto    lerr    ; 7b
225
 
226
pcl7a
227
        bcf     PCL,2   ; 7c
228
 
229
pcl7b
230
 
231
 
232
        ; Make sure goto works
233
        movlw   0x09    ;       TEST 9
234
        movwf   PORTB   ; Set Test Number
235
 
236
 
237
        goto    gt1
238
        nop
239
        nop
240
        nop
241
        nop
242
        movlw   0xff
243
        movwf   PORTA
244
        nop
245
        nop
246
        nop
247
        nop
248
gt1
249
 
250
        ; Make sure call works
251
        movlw   0x0a    ;       TEST 10
252
        movwf   PORTB   ; Set Test Number
253
 
254
        call    cal1
255
        movwf   r0
256
        movlw   0x55
257
        subwf   r0,w
258
        btfss   STATUS,Z
259
        goto    lerr
260
 
261
        call    cal2
262
        movwf   r0
263
        movlw   0xaa
264
        subwf   r0,w
265
        btfss   STATUS,Z
266
        goto    lerr
267
 
268
        call    cal3
269
        movwf   r0
270
        movlw   0xc3
271
        subwf   r0,w
272
        btfss   STATUS,Z
273
        goto    lerr
274
 
275
        call    cal4
276
        movwf   r0
277
        movlw   0x3c
278
        subwf   r0,w
279
        btfss   STATUS,Z
280
        goto    lerr
281
 
282
        goto    next1
283
 
284
cal1
285
        retlw   0x55
286
        goto    lerr
287
 
288
cal2
289
        nop
290
        retlw   0xaa
291
        goto    lerr
292
 
293
cal3
294
        nop
295
        nop
296
        retlw   0xc3
297
        goto    lerr
298
 
299
cal4
300
        nop
301
        nop
302
        nop
303
        retlw   0x3c
304
        goto    lerr
305
 
306
table1
307
        addwf   PCL,F
308
        retlw   0xff
309
        retlw   0xfe
310
        retlw   0xfd
311
        retlw   0xfc
312
        retlw   0xfb
313
        retlw   0xfa
314
        retlw   0xf9
315
        retlw   0xf8
316
        retlw   0xf7
317
        retlw   0xf6
318
        retlw   0xf5
319
        goto    lerr
320
        goto    lerr
321
        goto    lerr
322
        goto    lerr
323
        goto    lerr
324
        goto    lerr
325
 
326
next1
327
 
328
 
329
        ; Make sure call works (2)
330
        movlw   0x0b    ;       TEST 11
331
        movwf   PORTB   ; Set Test Number
332
 
333
        movlw   0x0
334
        movwf   r0
335
        call    table1
336
        comf    r0,F
337
        subwf   r0,F
338
        btfss   STATUS,Z
339
        goto    lerr
340
 
341
        movlw   0x1
342
        movwf   r0
343
        call    table1
344
        comf    r0,F
345
        subwf   r0,F
346
        btfss   STATUS,Z
347
        goto    lerr
348
 
349
        movlw   0x2
350
        movwf   r0
351
        call    table1
352
        comf    r0,F
353
        subwf   r0,F
354
        btfss   STATUS,Z
355
        goto    lerr
356
 
357
        movlw   0x3
358
        movwf   r0
359
        call    table1
360
        comf    r0,F
361
        subwf   r0,F
362
        btfss   STATUS,Z
363
        goto    lerr
364
 
365
        movlw   0x4
366
        movwf   r0
367
        call    table1
368
        comf    r0,F
369
        subwf   r0,F
370
        btfss   STATUS,Z
371
        goto    lerr
372
 
373
        movlw   0x5
374
        movwf   r0
375
        call    table1
376
        comf    r0,F
377
        subwf   r0,F
378
        btfss   STATUS,Z
379
        goto    lerr
380
 
381
        movlw   0x6
382
        movwf   r0
383
        call    table1
384
        comf    r0,F
385
        subwf   r0,F
386
        btfss   STATUS,Z
387
        goto    lerr
388
 
389
        movlw   0x7
390
        movwf   r0
391
        call    table1
392
        comf    r0,F
393
        subwf   r0,F
394
        btfss   STATUS,Z
395
        goto    lerr
396
 
397
        movlw   0x8
398
        movwf   r0
399
        call    table1
400
        comf    r0,F
401
        subwf   r0,F
402
        btfss   STATUS,Z
403
        goto    lerr
404
 
405
        movlw   0x9
406
        movwf   r0
407
        call    table1
408
        comf    r0,F
409
        subwf   r0,F
410
        btfss   STATUS,Z
411
        goto    lerr
412
 
413
        movlw   0xa
414
        movwf   r0
415
        call    table1
416
        comf    r0,F
417
        subwf   r0,F
418
        btfss   STATUS,Z
419
        goto    lerr
420
 
421
        nop
422
        nop
423
        nop
424
        nop
425
        movlw   0x01
426
        movwf   PORTA
427
        nop
428
        nop
429
        nop
430
        nop
431
good                    ; Loop in good on success
432
        goto    good
433
        nop
434
        nop
435
        nop
436
        nop
437
 
438
lerr
439
        movlw   0xff
440
        movwf   PORTA
441
 
442
        nop
443
        nop
444
        nop
445
        nop
446
lerr_loop               ; Loop in lerr on failure
447
        goto    lerr_loop
448
        nop
449
        nop
450
        nop
451
        nop
452
 
453
   END
454
 

powered by: WebSVN 2.1.0

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