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

Subversion Repositories k68

[/] [k68/] [trunk/] [sw/] [mon/] [68mon.s] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sybreon
                ORG     0
2
                DC.W    0,STACK         ;RESET: initial SSP
3
                DC.W    0,START         ;RESET: initial PC
4
                DC.W    0,BUS_ERROR
5
                DC.W    0,ADRS_ERROR
6
                DC.W    0,ILLEGAL_INST
7
                DC.W    0,DIV_ZERO
8
                DC.W    0,START         ;CHK not implemented
9
                DC.W    0,TRAP_V
10
;
11
                ORG     $7C             ;skip reserved vectors
12
                DC.W    0,LEVEL_7
13
                DC.W    0,TO_CHAR_IN    ;TRAP vector 0
14
                DC.W    0,TO_CHAR_OUT   ;TRAP vector 1
15
                DC.W    0,TO_CRLF       ;TRAP vector 2
16
                DC.W    0,TO_PRINT_MSG  ;TRAP vector 3
17
                DC.W    0,TO_PRINT_BYTE ;TRAP vector 4
18
                DC.W    0,TO_PRINT_WORD ;TRAP vector 5
19
                DC.W    0,TO_PRINT_LONG ;TRAP vector 6
20
                DC.W    0,TO_GET_BYTE   ;TRAP vector 7
21
                DC.W    0,TO_GET_ADDR   ;TRAP vector 8
22
                DC.W    0,GETCMD        ;TRAP vector 9
23
;
24
                ORG     $400            ;start of monitor
25
STACK           EQU     $9000
26
START           MOVEA.L #STACK,A7       ;init stack
27
                BSR     INIT_ACIA       ;init serial chip
28
                BSR     SIGN_ON         ;greet user
29
GETCMD          MOVEA.L #STACK,A7       ;init stack
30
                BSR     CRLF
31
                MOVE.B  #'*',D1         ;output command prompt
32
                BSR     CHAR_OUT
33
                CLR.L   D2              ;init command-text buffer
34
                MOVEA.L #$8F00,A6       ;load buffer location
35
                BSR     GETLINE         ;fill buffer with text
36
                MOVEA.L #$8F00,A6       ;reset buffer pointer
37
                BSR     SKIP_BLK        ;skip leading blanks
38
INCOM           MOVE.B  (A6)+,D1
39
                BSR     UPPER_CASE
40
                CMPI.B  #$0D,D1
41
                BEQ     SEARCH
42
                CMPI.B  #$20,D1         ;test for SP
43
                BEQ     SEARCH
44
                ROL.L   #8,D2           ;prepare D2 for new letter
45
                MOVE.B  D1,D2           ;insert it into D2
46
                BRA     INCOM           ;get next letter
47
SEARCH          MOVE.L  #5,D5           ;number of commands to check
48
                MOVEA.L #COMMANDS,A2    ;init command text pointer
49
                MOVEA.L #COM_ADRS,A1    ;init command address pointer
50
TEST_NEXT       CMP.L   (A2),D2         ;compare command text
51
                BEQ     DO_JUMP         ;branch if match
52
                ADDQ.L  #4,A2           ;point to abbreviated command
53
                CMP.L   (A2),D2         ;test again
54
                BEQ     DO_JUMP
55
                ADDQ.L  #4,A2           ;point to next command
56
                ADDQ.L  #4,A1           ;point to next address
57
                SUBQ.L  #1,D5           ;all commands checked yet?
58
                BNE     TEST_NEXT
59
                BRA     ERROR           ;illegal command entered
60
DO_JUMP         MOVEA.L (A1),A1         ;get command address
61
                JMP     (A1)            ;and go execute command
62
COMMANDS        DC.B   'DUMP'           ;full command name
63
                DC.B    0,0,0           ;abbreviated name
64
                DC.B   'D'
65
                DC.B   'GO  '
66
                DC.B    0,0,0
67
                DC.B   'G'
68
                DC.B   'EDIT'
69
                DC.B    0,0,0
70
                DC.B   'E'
71
                DC.B   'MOVE'
72
                DC.B    0,0,0
73
                DC.B   'M'
74
                DC.B   'HELP'
75
                DC.B    0,0,0
76
                DC.B   'H'
77
COM_ADRS        DC.W    0,DUMP          ;DUMP execution address
78
                DC.W    0,GO
79
                DC.W    0,EDIT
80
                DC.W    0,MOOV
81
                DC.W    0,HELP
82
;
83
DUMP            BSR     GET_ADDR        ;get the starting address
84
                ANDI.B  #$F0,D2         ;make lower nibble zero
85
                MOVEA.L D2,A4           ;A4 is memory read register
86
                BSR     GET_ADDR        ;get the ending address
87
                MOVEA.L D2,A5
88
ADR_OUT         BSR     CRLF            ;new line please
89
                MOVE.L  A4,D2           ;print address
90
                BSR     PRINT_LONG
91
                BSR     BLANK           ;and some blanks
92
                BSR     BLANK
93
BYTE_OUT        MOVE.B  (A4)+,D2        ;get a byte and increment A4
94
                BSR     PRINT_BYTE      ;print the byte
95
                BSR     BLANK
96
                MOVE.L  A4,D1           ;done 16 yet?
97
                ANDI.L  #$0F,D1
98
                BNE     BYTE_OUT
99
                SUBA.L  #16,A4          ;back up 16 bytes
100
                BSR     BLANK
101
ASCII_OUT       MOVE.B  (A4)+,D1        ;get a byte
102
                ANDI.B  #$7F,D1
103
                CMPI.B  #$20,D1         ;is it printable?
104
                BMI     UN_PRINT
105
                CMPI.B  #$7D,D1
106
                BMI     SEND_IT
107
UN_PRINT        MOVE.B  #$2E,D1         ;use period for unprintables
108
SEND_IT         BSR     CHAR_OUT        ;print the ASCII equivalent
109
                MOVE.L  A4,D2           ;done 16 yet?
110
                ANDI.L  #$0F,D2
111
                BNE     ASCII_OUT
112
                BSR     FREEZE          ;hold display?
113
                CMPA.L  A4,A5           ;done with dump?
114
                BMI     GETCMD
115
                BRA     ADR_OUT
116
;
117
GO              BSR     GET_ADDR        ;get execution address
118
                MOVEA.L D2,A1
119
                JMP     (A1)
120
;
121
MOOV            BSR     GET_ADDR        ;get starting address
122
                MOVEA.L D2,A1
123
                BSR     GET_ADDR        ;get ending address
124
                MOVEA.L D2,A2
125
                ADDA.L  #1,A2           ;include last location
126
                BSR     GET_ADDR        ;get destination address
127
                MOVEA.L D2,A3
128
MOOVEM          MOVE.B  (A1)+,(A3)+     ;move and increment pointers
129
                CMPA.L  A1,A2           ;at ending address yet?
130
                BNE     MOOVEM
131
                BRA     GETCMD
132
;
133
EDIT            BSR     GET_ADDR        ;get starting address
134
                MOVEA.L D2,A2           ;A2 is the memory pointer
135
NEW_DATA        BSR     CRLF            ;new line please
136
                MOVE.L  A2,D2           ;print data address
137
                BSR     PRINT_LONG
138
                BSR     BLANK
139
                MOVE.B  (A2),D2         ;get the data
140
                BSR     PRINT_BYTE      ;and show it
141
                MOVE.B  #'?',D1         ;output change prompt
142
                BSR     CHAR_OUT
143
                BSR     GET_BYTE_T      ;get new data
144
                CMPI.B  #'*',D2         ;no change requested?
145
                BNE     ENTER_IT        ;jump if new data entered
146
                MOVE.B  (A2),D1         ;get old data back
147
ENTER_IT        MOVE.B  D1,(A2)+        ;save data and increment pointer
148
                BSR     NEW_DATA
149
;
150
INIT_ACIA       MOVEA.L #$10000,A0      ;point to ACIA Control reg.
151
                MOVE.B  #3,(A0)         ;ACIA master reset
152
                MOVE.B  #$15,(A0)       ;select options
153
                RTS
154
;
155
INSTAT          MOVEA.L #$10000,A0      ;point to ACIA Status reg.
156
                MOVE.B  (A0),D0         ;get ACIA status
157
                ANDI.B  #1,D0           ;test RRDY bit
158
                RTS
159
;
160
CHAR_IN         BSR     INSTAT          ;check receiver status
161
                BEQ     CHAR_IN         ;loop if no character waiting
162
                MOVEA.L #$10002,A0      ;point to ACIA Data reg.
163
                MOVE.B  (A0),D1         ;get the ASCII character
164
                ANDI.B  #$7F,D1         ;strip off MSB
165
                RTS
166
;
167
CHAR_OUT        MOVEA.L #$10000,A0      ;point to ACIA Status reg.
168
CHAR_OUT2       MOVE.B  (A0),D0         ;read the ACIA status
169
                ANDI.B  #2,D0           ;check the TRDY bit
170
                BEQ     CHAR_OUT2       ;loop if not ready
171
                MOVEA.L #$10002,A0      ;point to ACIA Data reg.
172
                MOVE.B  D1,(A0)         ;send the character
173
                RTS
174
;
175
CRLF            MOVE.B  #$0D,D1         ;send ASCII CR
176
                BSR     CHAR_OUT
177
                MOVE.B  #$0A,D1         ;send ASCII LF
178
                BSR     CHAR_OUT
179
                RTS
180
;
181
BLANK           MOVE.B  #$20,D1         ;send ASCII SP
182
                BSR     CHAR_OUT
183
                RTS
184
;
185
PRINT_MSG       MOVE.B  (A3),D1         ;get a character
186
                CMP.B   #0,D1           ;end of message?
187
                BEQ     PRINT_MSG2
188
                BSR     CHAR_OUT        ;send character to display
189
                ADDQ.L  #1,A3           ;point to next character
190
                BRA     PRINT_MSG
191
PRINT_MSG2      RTS
192
;
193
SIGN_ON         MOVEA.L #HELLO,A3       ;get starting message address
194
                BSR     PRINT_MSG       ;send the message
195
                RTS
196
;
197
PRINT_BYTE      MOVE.L  D2,D1           ;init conversion register
198
                ROL.B   #4,D1           ;look at upper nibble first
199
                BSR     TO_ASCII        ;print ASCII equivalent
200
                MOVE.L  D2,D1           ;repeat for lower nibble
201
TO_ASCII        ANDI.B  #$0F,D1         ;strip off upper nibble
202
                ADDI.B  #$30,D1         ;add ASCII bias
203
                CMPI.B  #$3A,D1         ;test for alpha conversion
204
                BMI     NO_ADD
205
                ADDI.B  #7,D1           ;correct to 41H-47H (A-F)
206
NO_ADD          BSR     CHAR_OUT        ;send character
207
                RTS
208
;
209
PRINT_WORD      ROL.W   #8,D2           ;get upper 8 bits
210
                BSR     PRINT_BYTE      ;output first two characters
211
                ROL.W   #8,D2           ;now do the lower 8 bits
212
                BSR     PRINT_BYTE
213
                RTS
214
;
215
PRINT_LONG      SWAP    D2              ;get upper 16 bits
216
                BSR     PRINT_WORD      ;do 4 character conversion
217
                SWAP    D2              ;and repeat for lower word
218
                BSR     PRINT_WORD
219
                RTS
220
;
221
VALDIG          CMPI.B  #'G',D1         ;greater than F?
222
                BPL     ERROR
223
                CMPI.B  #'0',D1         ;less than 0?
224
                BMI     ERROR
225
                CMPI.B  #'9'+1,D1       ;is it now A-F?
226
                BPL     NEXT_TST
227
                RTS                     ;range is 0-9
228
NEXT_TST        CMPI.B  #'A',D1         ;less than A?
229
                BMI     ERROR
230
                RTS                     ;range is A-F
231
;
232
ERROR           MOVEA.L #WHAT,A3        ;get message pointer
233
                BSR     PRINT_MSG
234
                BRA     GETCMD          ;restart monitor program
235
WHAT            DC.B    $0D,$0A         ;newline
236
                DC.B   'What?'
237
                DC.B    $0D,$0A,0       ;newline and end characters
238
;
239
TO_HEX          SUBI.B  #$30,D1         ;remove ASCII bias
240
                CMPI.B  #$0A,D1         ;0-9?
241
                BMI     FIN_CONV
242
                SUBI.B  #7,D1           ;remove alpha bias
243
FIN_CONV        RTS
244
;
245
GET_BYTE_T      MOVEA.L #$8F00,A6       ;TRAP entry point
246
                BSR     GETLINE
247
                MOVEA.L #$8F00,A6
248
GET_BYTE        BSR     SKIP_BLK        ;MON entry point
249
                MOVE.B  (A6)+,D1        ;get first digit
250
                BSR     UPPER_CASE
251
                CMPI.B  #$0D,D1         ;test for CR
252
                BEQ     NO_CHAN
253
                CMPI.B  #$20,D1         ;test for SP
254
                BEQ     NO_CHAN
255
                BSR     VALDIG          ;check for valid digit
256
                BSR     TO_HEX          ;convert into hex
257
                ROL.B   #4,D1           ;move first digit
258
                MOVE.B  D1,D2           ;save first digit
259
                MOVE.B  (A6)+,D1        ;get second digit
260
                BSR     UPPER_CASE
261
                BSR     VALDIG          ;check for valid digit
262
                BSR     TO_HEX          ;convert into hex
263
                ADD.B   D2,D1           ;form final result
264
                MOVE.B  #'0',D2         ;change entered
265
                RTS
266
NO_CHAN         MOVE.B  #'*',D2         ;no change character
267
                RTS
268
;
269
GET_ADDR_T      MOVEA.L #$8F00,A6
270
                BSR     GETLINE
271
                MOVEA.L #$8F00,A6
272
GET_ADDR        BSR     SKIP_BLK
273
                CLR.L   D1              ;init temp register
274
                CLR.L   D2              ;init result register
275
NEXT_CHAR       MOVE.B  (A6)+,D1        ;get a character
276
                BSR     UPPER_CASE
277
                CMPI.B  #$0D,D1         ;exit if CR
278
                BEQ     EXIT_ADR
279
                CMPI.B  #$20,D1         ;exit if SP
280
                BEQ     EXIT_ADR
281
                BSR     VALDIG          ;test for valid digit
282
                BSR     TO_HEX          ;convert digit into hex
283
                ROL.L   #4,D2           ;prepare D2 for new digit
284
                ANDI.B  #$F0,D2
285
                ADD.B   D1,D2           ;insert new digit
286
                BRA     NEXT_CHAR       ;and continue
287
EXIT_ADR        RTS
288
;
289
PANIC           BSR     INSTAT          ;check for key
290
                BEQ     EXIT_BRK        ;return if none hit
291
TEST_KEY        BSR     CHAR_IN         ;get key
292
TEST_KEY2       CMPI.B  #3,D1           ;Control-C?
293
                BEQ     GETCMD          ;if yes, restart monitor
294
EXIT_BRK        RTS
295
;
296
FREEZE          BSR     INSTAT          ;check for key
297
                BEQ     EXIT_FREZ       ;return if none hit
298
                BSR     CHAR_IN         ;get key
299
                CMPI.B  #$13,D1         ;Control-S?
300
                BEQ     HOLD_IT
301
                BRA     TEST_KEY2       ;Control-C?
302
EXIT_FREZ       RTS
303
HOLD_IT         BSR     INSTAT          ;wait for another key
304
                BEQ     HOLD_IT
305
                BRA     TEST_KEY        ;let PANIC check for Control-C
306
;
307
UPPER_CASE      CMPI.B  #'a',D1         ;check for lower case
308
                BMI     NO_CHG
309
                CMPI.B  #'z'+1,D1       ;first code after 'z'
310
                BPL     NO_CHG
311
                ANDI.B  #$DF,D1         ;switch to upper case
312
NO_CHG          RTS
313
;
314
GETLINE         MOVEA.L A6,A5           ;copy pointer
315
GETLINE2        MOVEA.L A5,A6           ;reset pointer and
316
                CLR.B   D6              ;counter for scraped lines
317
GET_CHARS       BSR     CHAR_IN         ;get character
318
                CMPI.B  #$0D,D1         ;CR ends get line
319
                BEQ     EXIT
320
                CMPI.B  #$08,D1         ;back space key and the
321
                BEQ     BKSPS           ;delete key are
322
CHECK_DELETE    CMPI.B  #$7F,D1         ;back space keys
323
                BEQ     BKSPS
324
                CMPI.B  #$15,D1         ;check for ^U and scrap the
325
                BEQ     LINE_REDO       ;line if encountered
326
                MOVE.B  D1,(A6)+        ;otherwise place character
327
                ADDQ.B  #1,D6           ;in buffer, update counter and
328
                BSR     CHAR_OUT            ;echo it to the screen
329
                BRA     GET_CHARS       ;get another character
330
EXIT            MOVE.B  D1,(A6)         ;on exit place $0D in buffer and
331
                ADDQ.B  #1,D6           ;count it
332
                BSR     CRLF
333
                RTS
334
LINE_REDO       BSR     CRLF            ;clean up the screen
335
                BRA     GETLINE2        ;start over
336
BKSPS           CMPI.B  #0,D6
337
                BEQ     GET_CHARS
338
                SUBQ.B  #1,D6
339
                SUBA.L  #1,A6
340
                MOVE.B  #8,D1
341
                BSR     CHAR_OUT
342
                MOVE.B  #' ',D1
343
                BSR     CHAR_OUT
344
                MOVE.B  #8,D1
345
                BSR     CHAR_OUT
346
                BRA     GET_CHARS
347
;
348
SKIP_BLK        CMPI.B  #' ',(A6)
349
                BNE     EXIT_SKIP
350
                ADDA.L  #1,A6
351
                BRA     SKIP_BLK
352
EXIT_SKIP       RTS
353
;
354
BUS_ERROR       MOVEA.L #MSG_1,A3
355
                BRA     REPORT
356
ADRS_ERROR      MOVEA.L #MSG_2,A3
357
                BRA     REPORT
358
ILLEGAL_INST    MOVEA.L #MSG_3,A3
359
                BRA     REPORT
360
DIV_ZERO        MOVEA.L #MSG_4,A3
361
                BRA     REPORT
362
TRAP_V          MOVEA.L #MSG_5,A3
363
                BRA     REPORT
364
LEVEL_7         MOVEA.L #MSG_6,A3
365
                BRA     REPORT
366
TO_CHAR_IN      BSR     CHAR_IN
367
                RTE
368
TO_CHAR_OUT     BSR     CHAR_OUT
369
                RTE
370
TO_CRLF         BSR     CRLF
371
                RTE
372
TO_PRINT_MSG    BSR     PRINT_MSG
373
                RTE
374
TO_PRINT_BYTE   BSR     PRINT_BYTE
375
                RTE
376
TO_PRINT_WORD   BSR     PRINT_WORD
377
                RTE
378
TO_PRINT_LONG   BSR     PRINT_LONG
379
                RTE
380
TO_GET_BYTE     BSR     GET_BYTE_T
381
                RTE
382
TO_GET_ADDR     BSR     GET_ADDR_T
383
                RTE
384
HELP            MOVEA.L #H_MSG1,A3
385
REPORT          BSR     CRLF            ;new line thank you
386
                BSR     PRINT_MSG       ;print message pointed to by A3
387
                BSR     CRLF
388
                BRA     GETCMD
389
 
390
MSG_1           DC.B    'Bus Error',0
391
MSG_2           DC.B    'Address Error',0
392
MSG_3           DC.B    'Illegal Instruction Error',0
393
MSG_4           DC.B    'Divide by Zero Error',0
394
MSG_5           DC.B    'TRAPV Overflow',0
395
MSG_6           DC.B    'Level-7 Interrupt',0
396
 
397
HELLO           DC.B    $0D,$0A         ;newline
398
                DC.B   '68000 Monitor, Version 7.5, C1995 JLACD'
399
                DC.B    $0D,$0A,0       ;newline and end characters
400
 
401
H_MSG1          DC.B    $0D,$0A,$0D,$0A
402
                DC.B    '*** 68000 Cpu-based Single Board Computer ***'
403
                DC.B    $0D,$0A
404
                DC.B    'Command Syntax         Action'
405
                DC.B    $0D,$0A,$0D,$0A
406
                DC.B    'DUMP 400 44F           Display memory contents'
407
                DC.B    $0D,$0A
408
                DC.B    '                       Ctrl-S freezes display'
409
                DC.B    $0D,$0A
410
                DC.B    '                       Any key restarts display'
411
                DC.B    $0D,$0A
412
                DC.B    '                       Ctrl-C cancels dump'
413
                DC.B    $0D,$0A,$0D,$0A
414
                DC.B    'EDIT 8000              Load RAM starting at 8000'
415
                DC.B    $0D,$0A
416
                DC.B    '                       Use CR or blank to keep data'
417
                DC.B    $0D,$0A
418
                DC.B    '                       Ctrl-C cancels patching'
419
                DC.B    $0D,$0A,$0D,$0A
420
                DC.B    'GO 8000                Execute program at 8000'
421
                DC.B    $0D,$0A,$0D,$0A
422
                DC.B    'MOVE 8000 80FF 8100    Move memory contents'
423
                DC.B    $0D,$0A,$0D,$0A
424
                DC.B    'All commands may be shortened to single letters.'
425
                DC.B    $0D,$0A
426
                DC.B    'Use D, E, G, M, or H. Lower case characters'
427
                DC.B    $0D,$0A
428
                DC.B    'as well.'
429
                DC.B    $0D,$0A,$0D,$0A
430
                DC.B    'This 68000 system was designed and programmed by'
431
                DC.B    $0D,$0A
432
                DC.B    'James Antonakos, Alan Dixon and Donovan McCarty.'
433
                DC.B    $0D,$0A,0
434
                END     START
435
 

powered by: WebSVN 2.1.0

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