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

Subversion Repositories risc5x

[/] [risc5x/] [trunk/] [jumptest.asm] - Blame information for rev 5

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

Line No. Rev Author Line
1 2 mikej
;
2
        LIST    p=16C58 ; PIC16C58 is the target processor
3
 
4
 
5
;
6
; Core Sanity Test
7
;
8
; JUMPTEST.ASM
9
;
10
; test some jumps
11
; NEW in rev 1.1, test indirect addressing
12
; test some inc & decs
13
; sit in loop multiplying port A with a constant
14
; output 16 bit result on ports C & B
15
;
16
 
17
CARRY   equ     H'00'   ; Carry bit in STATUS register
18
DC      equ     H'01'   ; DC    bit in STATUS register
19
ZERO    equ     H'02'   ; Zero  bit in STATUS register
20
W       equ     H'00'   ; W indicator for many instruction (not the address!)
21
 
22
INDF    equ     H'00'   ; Magic register that uses INDIRECT register
23
TIMER0  equ     H'01'   ; Timer register
24
PC      equ     H'02'   ; PC
25
STATUS  equ     H'03'   ; STATUS register F3
26
FSR     equ     H'04'   ; INDIRECT Pointer Register
27
porta   equ     H'05'   ; I/O register F5
28
portb   equ     H'06'   ; I/O register F6
29
portc   equ     H'07'   ; I/O register F7
30
x       equ     H'09'   ; scratch
31
y       equ     H'0A'   ; scratch
32
rh      equ     H'0B'   ; result h
33
rl      equ     H'0C'   ; result l
34
 
35
mult    MACRO   bit
36
        btfsc   y,bit
37
        addwf   rh,1
38
        rrf     rh,1
39
        rrf     rl,1
40
        ENDM
41
 
42
start:  movlw   H'ff'
43
        tris    porta   ; PORTA is Input
44
        clrw
45
        tris    portb   ; PORTB is Output
46
        tris    portc   ; PORTC is Output
47
        movwf   portb   ; PORTB <= 00
48
 
49
        movlw   h'0B'
50
        movwf   PC      ; move to pc (jump1)
51
 
52
        movlw   h'F0'   ; fail 0
53
        movwf   portb
54
        goto fail
55
 
56
jump1:  movlw   h'05'
57
        addwf   PC,f   ; jump forward to jump2
58
        movlw   h'F1'   ; fail 1
59
        movwf   portb
60
        goto fail
61
 
62
jump3:  goto    jump4   ; continue
63
        nop
64
 
65
jump2:  movlw   h'04'
66
        subwf   PC, f   ; jump back to jump 3
67
 
68
        movlw   h'F2'   ; fail 2
69
        movwf   portb
70
        goto fail
71
 
72
jump4:
73
        movlw   h'10'   ; set locations 10-1F to xFF
74
        movwf   FSR
75
        movlw   h'ff'
76
clrlp:  movwf   INDF
77
        incf    FSR,F
78
        btfsc   FSR,4
79
        goto clrlp
80
 
81
        movlw   h'10'
82
        movwf   x
83
        movlw   h'20'
84
        movwf   y
85
 
86
        movlw   x
87
        movwf   FSR     ; point FSR at x
88
 
89
        movf    FSR,w
90
        xorlw   h'89'   ; check its x (note bit 7 set always)
91
        btfss   STATUS,ZERO
92
        goto    fail
93
        movf    INDF,w
94
        xorlw   h'10'   ; check its 10
95
        btfss   STATUS,ZERO
96
        goto    fail
97
 
98
        movlw   h'15'   ; write 15 to x using INDF
99
        movwf   INDF
100
        movf    x,w     ; read x
101
        xorlw   h'15'   ; check its 15
102
        btfss   STATUS,ZERO
103
        goto    fail
104
 
105
        incf    FSR,F
106
        movf    INDF,w
107
        xorlw   h'20'   ; check its 20
108
        btfss   STATUS,ZERO
109
        goto    fail
110
 
111
        movlw   h'00'
112
        movwf   FSR
113
        movlw   h'A5'   ; paranoid !
114
        movf    INDF,w  ; reading INDR itself should = 0
115
        xorlw   h'00'   ; check
116
        btfss   STATUS,ZERO
117
        goto    fail
118
 
119
        ; check banking
120
        ; locations 20-2F, 40-4F, 60-6F all map to 0-0F
121
        ; locations 10-1F, 30-3F, 50-5F, 70-7F are real
122
 
123
 
124
        movlw   h'00'
125
        movwf   FSR     ; set bank 0
126
        movlw   h'1F'
127
        movwf   h'1F'
128
 
129
        movlw   h'20'
130
        movwf   FSR     ; set bank 1
131
        movlw   h'3F'
132
        movwf   h'1F'
133
 
134
        movlw   h'40'
135
        movwf   FSR     ; set bank 2
136
        movlw   h'5F'
137
        movwf   h'1F'
138
 
139
        movlw   h'60'
140
        movwf   FSR     ; set bank 3
141
        movlw   h'7F'
142
        movwf   h'1F'
143
        ; check
144
 
145
        movlw   h'00'
146
        movwf   FSR     ; set bank 0
147
        movf    h'1F',w
148
        xorlw   h'1F'
149
        btfss   STATUS,ZERO
150
        goto    fail
151
 
152
        movlw   h'20'
153
        movwf   FSR     ; set bank 1
154
        movf    h'1F',w
155
        xorlw   h'3F'
156
        btfss   STATUS,ZERO
157
        goto    fail
158
 
159
        movlw   h'40'
160
        movwf   FSR     ; set bank 2
161
        movf    h'1F',w
162
        xorlw   h'5F'
163
        btfss   STATUS,ZERO
164
        goto    fail
165
 
166
        movlw   h'60'
167
        movwf   FSR     ; set bank 3
168
        movf    h'1F',w
169
        xorlw   h'7F'
170
        btfss   STATUS,ZERO
171
        goto    fail
172
 
173
        movlw   h'00'
174
        movwf   FSR     ; set bank 0
175
 
176
        movlw   h'45'
177
        movwf   h'0F'
178
 
179
        movlw   h'60'
180
        movwf   FSR     ; set bank 3
181
        movlw   h'54'
182
        movwf   h'0F'
183
 
184
        movlw   h'40'
185
        movwf   FSR     ; set bank 2
186
        movf    h'0f',w ; w should contain 54
187
 
188
        xorlw   h'54'
189
        btfsc   STATUS,ZERO
190
        goto test1
191
 
192
        movlw   h'F3'   ; fail 3
193
        movwf   portb
194
 
195
        goto fail
196
 
197
test1:  movlw   h'00'
198
        movwf   FSR     ; set bank 0
199
        movlw   h'04'   ; w <= 04
200
        movwf   x
201
        decf    x,f     ; x <= 03
202
        decf    x,f     ; x <= 02
203
        decf    x,f     ; x <= 01
204
        decf    x,f     ; x <= 00
205
        decf    x,f     ; x <= FF
206
        movf    x,w
207
        xorlw   h'FF'   ; does w = ff ?
208
        btfss   STATUS,ZERO ; skip if clear
209
        goto    fail
210
        incf    x,f     ; x <= 00
211
        incf    x,f     ; x <= 01
212
        movf    x,w
213
        xorlw   h'01'   ; does w = 01
214
        btfss   STATUS,ZERO
215
        goto    fail
216
 
217
        ; test logic
218
 
219
        clrf    x       ; x <= 00
220
        movlw   h'a5'
221
        iorwf   x,f     ; x <= a5
222
        swapf   x,f     ; x <= 5a
223
        movlw   h'f0'
224
        andwf   x,f     ; x <= 50
225
        comf    x,f     ; x <= af
226
        movlw   h'5a'
227
        xorwf   x,f     ; x <= f5
228
 
229
        ;check
230
        movfw   x
231
        xorlw   h'f5'
232
        btfsc   STATUS,ZERO
233
        goto test2
234
        movlw   h'F4'   ; fail 4
235
        movwf   portb
236
        goto fail
237
 
238
test2:  movlw   h'23'
239
        movwf   x       ; x <= 23
240
        movlw   h'e1'   ; w <= e1
241
        addwf   x,f     ; x <= 04
242
        btfss   STATUS,CARRY
243
        goto    fail    ; carry should be set
244
        movlw   h'02'   ; w <= 02
245
        subwf   x,f     ; x <= 02
246
        btfss   STATUS,CARRY
247
        goto    fail    ; borrow should be clear
248
 
249
        movlw   h'34'   ; w <= 34
250
        subwf   x,f     ; x <= ce
251
        btfsc   STATUS,CARRY
252
        goto    fail    ; borrow should be set
253
 
254
        movf    x,w
255
        xorlw   h'CE'
256
        btfss   STATUS,ZERO
257
        goto    fail    ; x /= ce
258
 
259
test3:  movlw   h'34'   ; test dc flag
260
        movwf   x
261
        movlw   h'0F'
262
        addwf   x,f     ; x <= 43
263
        btfsc   STATUS,CARRY
264
        goto    fail    ; carry should be clear
265
        btfss   STATUS,DC
266
        goto    fail    ; dc should be set
267
        movlw   h'01'
268
        subwf   x,f     ; x <= 42
269
        btfss   STATUS,CARRY
270
        goto    fail    ; borrow should be clear
271
        btfss   STATUS,DC
272
        goto    fail    ; dc borrow should be clear
273
        movlw   h'FF'
274
        subwf   x,f
275
        btfsc   STATUS,CARRY
276
        goto    fail    ; borrow should be set
277
        btfsc  STATUS,DC
278
        goto    fail    ; dc borrow should be set
279
 
280
        movf    x,w
281
        xorlw   h'43'   ; final check
282
        btfss   STATUS,ZERO
283
        goto    fail    ; x /= 43
284
        movlw   h'E0'   ; ok
285
        movwf   portb
286
 
287
loop1:                  ; mult x by y
288
        movf    porta,W
289
        movwf   x
290
        movlw   h'23'
291
        movwf   y
292
 
293
        clrf    rh
294
        clrf    rl
295
        movf    x,w
296
        bcf     STATUS,CARRY
297
        mult    0
298
        mult    1
299
        mult    2
300
        mult    3
301
        mult    4
302
        mult    5
303
        mult    6
304
        mult    7
305
 
306
        movf    rl,w
307
        movwf   portb   ; on port b low result
308
        movf    rh,w
309
        movwf   portc   ; on port c high result
310
        goto    loop1
311
 
312
fail:   goto    fail
313
        end

powered by: WebSVN 2.1.0

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