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

Subversion Repositories m32632

[/] [m32632/] [trunk/] [TRIPUTER/] [monitor.32K] - Blame information for rev 44

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

Line No. Rev Author Line
1 35 ns32kum
; MONITOR for TRIPUTER V0.1
2
; 27 May 2017
3
sramsize  .equ x'8000
4
 
5
        movd x'20000010,r0
6
        jump r0
7
 
8
        .align 16
9
        movd x'20400000,r1      ; address of LEDs
10
        movqd 0,0(r1)           ; all went off
11
        movd x'FFFF,4(r1)               ; the seven segment went off
12
        lprd cfg,x'BF6
13
        lprd sp,x'300
14
        lprd intbase,x'300
15
        addr nmi,@x'304
16
        movd x'20200000,r7      ; UART - fix Register
17
        addr welcome,r0
18
        bsr string
19
; SRAM-Test : Bit Test
20
        movqw 1,r2
21
        movd x'20100000,r3
22
l01:    movw r2,0(r3)           ; write
23
        addqd 2,r3
24
        addw r2,r2
25
        cmpqw 0,r2
26
        bne l01
27
        movqw 1,r2
28
        movqw 0,r3
29
l02:  cmpw 0(r3),r2             ; read
30
        bne err
31
        addqd 2,r3
32
        addw r2,r2
33
        cmpqw 0,r2
34
        bne l02
35
        movl datfp,-15(r3)
36
        cmpl datfp,-15(r3)
37
        bne err
38
; Address steping
39
        movd x'20100000,r3
40
        movd x'20000,r2         ; Initialize on 0
41
l03:    movqd 0,0(r3)
42
        addqd 4,r3
43
        acbd -1,r2,l03
44
        movd x'20100000,r3      ; Test of 0 and 1 write
45
        movd x'40000,r2
46
l04:    cmpqw 0,0(r3)
47
        bne err
48
        movqw -1,0(r3)
49
        addqd 2,r3
50
        acbd -1,r2,l04
51
        movd x'20100000,r3      ; Test on 1 and 0 write
52
        movd x'40000,r2
53
l05:    cmpqw -1,0(r3)
54
        bne err
55
        movqw 0,0(r3)
56
        addqd 2,r3
57
        acbd -1,r2,l05
58
        movd x'20100000,r3      ; Test on 0
59
        movd x'40000,r2
60
l06:    cmpqw 0,0(r3)
61
        bne err
62
        addqd 2,r3
63
        acbd -1,r2,l06
64
        addr sram_ok,r0
65
        bsr string
66
; INT vector points to SRAM
67
        movd x'20100300,r3
68
        addr nmi,4(r3)
69
        addr int,0(r3)
70
        lprd intbase,r3
71
        lprd sp,x'20100300
72
        lprd sb,x'20100400      ; working area
73
        movqd 0,-4(sb)          ; counter in NMI
74
        sbitb 31,x'300004(r7)   ; NMI enable
75
; iDRAM-Test : Bit Test
76
        movqd 1,r2
77
        movqd 0,r3
78
l21:    movd r2,0(r3)           ; write
79
        addqd 4,r3
80
        addd r2,r2
81
        cmpqd 0,r2
82
        bne l21
83
        movqd 1,r2
84
        movqd 0,r3
85
l22:  cmpd 0(r3),r2             ; read
86
        bne err
87
        addqd 4,r3
88
        addd r2,r2
89
        cmpqd 0,r2
90
        bne l22
91
        movl datfp,-15(r3)
92
        cmpl datfp,-15(r3)
93
        bne err
94
; Address stepping
95
        movqd 0,r3
96
        movw sramsize,r2                ; Initialize to 0
97
l23:    movqd 0,0(r3)
98
        addqd 4,r3
99
        acbw -1,r2,l23
100
        movqd 0,r3                      ; Test on 0 and 1 write
101
        movw sramsize,r2
102
l24:    cmpqd 0,0(r3)
103
        bne err
104
        movqd -1,0(r3)
105
        addqd 4,r3
106
        acbw -1,r2,l24
107
        movqd 0,r3                      ; Test on 1 und 0 write
108
        movd sramsize,r2
109
l25:    cmpqd -1,0(r3)
110
        bne err
111
        movqd 0,0(r3)
112
        addqd 4,r3
113
        acbw -1,r2,l25
114
        movqd 0,r3                      ; Test on 0
115
        movw sramsize,r2
116
l26:    cmpqd 0,0(r3)
117
        bne err
118
        addqd 4,r3
119
        acbw -1,r2,l26
120
; Now all Data right initialize
121
        movd x'300,r0
122
        lprd sp,r0
123
        lprd sb,x'400           ; working area
124
        addr int,0(r0)
125
        addr nmi,4(r0)
126
        lprd intbase,r0
127
        movqd 0,-8(sb)          ; readpointer of RX buffer
128
        movqd 0,-12(sb)         ; writepointer of RX buffer
129
        movqb 0,-4(sb)          ; count byte for NMI
130
        movqd 0,-20(sb)         ; pointer for Dump
131
        addr idram_ok,r0
132
        bsr string
133
        bispsrw x'800           ; Int enable
134
        sbitb 9,0(r7)           ; UART RX Int on
135
        addr string,-24(sb)     ; save address of string service routine
136
; ***************************************************************
137
; Endless loop : wait on Input from UART
138
; ***************************************************************
139
new:    movd x'20240002,-2(sb)
140
        sprd sb,r0
141
        bsr string
142
        movqd 0,-16(sb)         ; Number of characters in buffer
143
loop:   wait
144
        cmpd -8(sb),-12(sb)     ; has the UART something received?
145
        beq loop                        ; No
146
; Auswertung
147
        movd -8(sb),r1
148
        movb x'100(sb)[r1:b],r0
149
        addqb 1,-8(sb)
150
        checkb r1,cvalid,r0     ; special character ?
151
        bfs sys1                        ; Yes
152
        movd -16(sb),r1
153
        cmpqd 0,r1
154
        bne sys2
155
        cmpb '+',r0
156
        beq sys3
157
        cmpb '-',r0
158
        beq sys4
159
sys2:   movb r0,0(sb)[r1:b]
160
        addr 1(r1),-16(sb)
161
sys0:   bsr out
162
        br loop
163
sys1:   cmpb 8,r0                       ; Delete
164
        bne sys5
165
        cmpqd 0,-16(sb)
166
        beq loop
167
        addqd -1,-16(sb)
168
        bsr out
169
        movb ' ',r0
170
        bsr out
171
        movb 8,r0
172
        br sys0
173
sys5:   cmpb 13,r0                      ; CR only output
174
        beq sys0
175
        cmpb 10,r0                      ; LF now analyzing input
176
        bne new
177
; Analyzing input:
178
        bsr out
179
        sprd sb,r2
180
        movd -16(sb),r1         ; Number of characters in buffer
181
sys7:   cmpqd 0,r1
182
        beq new
183
        movb 0(r2),r0
184
        addqd 1,r2
185
        addqd -1,r1
186
        cmpb ' ',r0
187
        beq sys7                        ; next character
188
        bicb x'20,r0            ; only capital letters
189
        movqd 0,r6
190
        cmpb 'L',r0                     ; "Load"
191
        beq sys6
192
        movqd 1,r6
193
        cmpb 'R',r0                     ; "Run"
194
        beq sys6
195
        movqd 2,r6
196
        cmpb 'D',r0                     ; "Dump"
197
        beq sys6
198
        br erin                 ; Error in input
199
; now look for ' ' and address input
200
sys6: cmpqd 0,r1
201
        beq erin                        ; no input any more
202
        cmpb ' ',0(r2)
203
        addqd 1,r2
204
        addqd -1,r1
205
        bne sys6
206
; now look for characters
207
sys8:   cmpqd 0,r1
208
        beq erin
209
        cmpb ' ',0(r2)
210
        addqd 1,r2
211
        addqd -1,r1
212
        beq sys8
213
; Addresse build
214
        movqd 0,r4
215
sy10:   movb -1(r2),r3
216
        checkb r5,cziff,r3
217
        bfc sy11
218
        bicb x'20,r3
219
        checkb r5,cabc,r3
220
        bfs erin                        ; illegal character -> Abort
221
        addb 10,r5
222
sy11:   ashd 4,r4
223
        orb r5,r4
224
        cmpqd 0,r1
225
        beq sys9
226
        addqd 1,r2
227
        addqd -1,r1
228
        br sy10
229
; Now execute ...
230
        .align 4
231
sys9: casew sy12[r6:w]
232
sy12:   .word syld-sys9
233
        .word sygo-sys9
234
        .word sydu-sys9
235
; Program Call
236
sygo:   jsr r4
237
        movd x'20200000,r7
238
        br new
239
; make Dump , R4 is pointer
240
sys4:   subd 512,-20(sb)
241
sys3:   movd -20(sb),r4
242
        movb 13,r0                      ; make CR before
243
        bsr out
244
sydu:   movb 16,r5                      ; Number of Lines
245
sy18:   sprd sb,r0                      ; Pointer to String
246
        movzbd 28,r1
247
sy13:   extd r1,r4,r2,4
248
        movb datah[r2:b],0(r0)
249
        addqd 1,r0
250
        addqb -4,r1
251
        cmpqb -4,r1
252
        bne sy13
253
        movb 16,r6
254
sy15:   movb ' ',0(r0)
255
        addqd 1,r0
256
        addr -1(r6),r2
257
        andb 3,r2
258
        cmpqb 3,r2
259
        bne sy14
260
        movb ' ',0(r0)
261
        addqd 1,r0
262
sy14: extsd 0(r4),r2,4,4
263
        movb datah[r2:b],0(r0)
264
        extsd 0(r4),r2,0,4
265
        movb datah[r2:b],1(r0)
266
        addqd 2,r0
267
        addqd 1,r4
268
        acbb -1,r6,sy15
269
        movw x'2720,0(r0)
270
        addqd 2,r0
271
        addr -16(r4),r4
272
        movb 16,r6
273
sy16:   movb 0(r4),r2
274
        checkb r1,cvalid,r2
275
        bfc sy17
276
        movb '.',r2
277
sy17:   movb r2,0(r0)
278
        addqd 1,r0
279
        addqd 1,r4
280
        acbb -1,r6,sy16
281
        movd x'0A0D27,0(r0)
282
        addqd 3,r0
283
        movzbw r0,-2(sb)
284
        sprd sb,r0
285
        bsr string
286
        acbb -1,r5,sy18
287
        movd r4,-20(sb)
288
        br new
289
; Example:
290
; ":200000006DA60BF757A000000C80CF0F00D7A1FFFFFE00D4A315165C7810D4A30D185C7800"
291
; ":007FE001A0"
292
; R4 pointer to memory
293
; R5 "0" counter
294
syld:   movqd 0,r5
295
sy23:   bsr getchar
296
        cmpb ':',r0
297
        bne abort                       ; Abort if not ':' - what happens after this don't care
298
        movqd 0,r6                      ; Checksum=0
299
        bsr getbyte
300
        cmpqb 0,r0
301
        beq sy19                        ; End
302
        movb r0,r1
303
        bsr getbyte
304
        movzbd r0,r2
305
        lshd 8,r2
306
        bsr getbyte
307
        movb r0,r2
308
        bsr getbyte
309
        cmpqb 0,r0
310
        bne abort                       ; if not 0 - Abort. Limited to 64K
311
sy20:   bsr getbyte
312
        movb r0,r4[r2:b]
313
        addqd 1,r2
314
        addqd 1,r5
315
        acbb -1,r1,sy20
316
        bsr getbyte
317
        cmpqd 0,r6
318
        bne abort
319
sy21:   bsr getchar                     ; CR and LF read
320
        cmpb 10,r0                      ; there are Files without CR !
321
        bne sy21
322
; show how many load up to now R2 -> decimal
323
        movd 10000,r0
324
        addr 1(sb),r3
325
        movd x'D0006,-2(sb)
326
        movd r5,r2
327
sy22:   movd r2,r1
328
        divd r0,r1
329
        orb x'30,r1
330
        movb r1,0(r3)
331
        addqd 1,r3
332
        modd r0,r2
333
        divd 10,r0
334
        cmpqd 0,r0
335
        bne sy22
336
        sprd sb,r0
337
        bsr string
338
        br sy23
339
; ******* Load finished *******
340
sy19: movqb 4,r1
341
sy24:   bsr getbyte
342
        acbb -1,r1,sy24
343
        cmpqd 0,r6
344
        bne abort
345
sy25:   bsr getchar                     ; CR and LF read
346
        cmpb 10,r0
347
        bne sy25
348
        addr crlf,r0
349
sy26:   bsr string
350
        br new
351
 
352
erin:   addr erinfo,r0
353
        br sy26
354
 
355
getchar:
356
        save [r1]
357
gec1:   cmpd -8(sb),-12(sb)
358
        beq gec1
359
        movd -8(sb),r1
360
        movb x'100(sb)[r1:b],r0
361
        addqb 1,-8(sb)
362
        restore [r1]
363
        ret 0
364
 
365
getbyte:
366
        save [r1,r2]
367
        bsr getchar
368
        checkb r1,cziff,r0
369
        bfc geb1
370
        bicb x'20,r0
371
        checkb r1,cabc,r0
372
        bfc geb2
373
        orw x'A00,r6
374
geb2:   addb 10,r1
375
geb1:   ashd 4,r1
376
        bsr getchar
377
        checkb r2,cziff,r0
378
        bfc geb3
379
        bicb x'20,r0
380
        checkb r2,cabc,r0
381
        bfc geb4
382
        orw x'A00,r6
383
geb4:   addb 10,r2
384
geb3:   orb r2,r1
385
        addb r1,r6                      ; add to Checksum
386
        movb r1,r0
387
        restore [r1,r2]
388
        ret 0
389
 
390
abort:
391
        addr lderr,r0
392
        bsr string
393
        br new
394
 
395
out:    tbitb 11,0(r7)
396
        bfs out
397
        movb r0,0(r7)
398
        ret 0
399
 
400
string:
401
        save [r1,r7]
402
        movd x'20200000,r7
403
        movw -2(r0),r1
404
st3:    cmpqw 0,r1
405
        beq st1
406
st2:    tbitb 11,0(r7)
407
        bfs st2
408
        movb 0(r0),0(r7)
409
        addqd 1,r0
410
        acbw -1,r1,st2
411
st1:    restore [r1,r7]
412
        ret 0
413
 
414
datal:  ; 0     1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
415
 .byte x'3F,6,x'5B,x'4F,x'66,x'6D,x'7D,x'07,x'7F,x'6F,x'77,x'7C,x'39,x'5E,x'79,x'71
416
 
417
datah: .byte '0123456789ABCDEF'
418
 
419
        .align 4
420
datfp:  .double x'87654321,x'0FEDCBA9
421
cvalid: .byte x'7E,x'20
422
cziff:  .byte '90'
423
cabc:           .byte 'FA'
424
 
425
                .word txt_1-sram_ok
426
sram_ok:        .byte '512K SRAM ok.',13,10
427
txt_1:  .word txt_2-welcome
428
welcome:        .byte 13,10,'Hardware: TRIPUTER V0.1 , 27 May 2017'
429
                .byte 13,10,'Software: MONITOR  V0.1 , 27 May 2017',13,10
430
txt_2:  .word txt_3-idram_ok
431
idram_ok:       .byte '128K iDRAM ok.',13,10
432
txt_3:  .word txt_4-error
433
error:  .byte 'Memory Fault !!!',13,10
434
txt_4:  .word txt_6-lderr
435
lderr:  .byte 13,10,'Error in Load!',13,10
436
txt_6:  .word txt_7-crlf
437
crlf:           .byte 13,10
438
txt_7:  .word txt_8-erinfo
439
erinfo: .byte 'Error in input!',13,10
440
txt_8:
441
 
442
        .align 4
443
nmi:    save [r0,r1]
444
        movb -4(sb),r0
445
        extsd r0,r1,0,4
446
        comb datal[r1:b],x'200004(r7)
447
        extsd r0,r1,4,4
448
        comb datal[r1:b],x'200005(r7)
449
        bispsrb 1
450
        addpb 0,r0
451
        cmpb x'60,r0
452
        beq nmi1
453
nmi2:   movb r0,-4(sb)
454
        restore [r0,r1]
455
        rett 0
456
nmi1:   movqb 0,r0
457
        br nmi2
458
 
459
        .align 4
460
int:    save [r0]               ; RX UART
461
        movd -12(sb),r0
462
        movb 0(r7),x'100(sb)[r0:b]
463
        addqb 1,-12(sb)
464
        movb x'100(sb)[r0:b],x'200000(r7)
465
        movb r0,x'200002(r7)
466
        restore [r0]
467
        reti
468
 
469
err:    addr error,r0
470
        bsr string
471
err1:   comw x'4040,4(r1)       ; 0 = leuchten
472
        br err1
473
 

powered by: WebSVN 2.1.0

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