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

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [boot_tb/] [debugger.asm] - Blame information for rev 36

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

Line No. Rev Author Line
1 28 robfinch
; ============================================================================
2
;        __
3
;   \\__/ o\    (C) 2015  Robert Finch, Stratford
4
;    \  __ /    All rights reserved.
5
;     \/_//     robfinch@finitron.ca
6
;       ||
7
;
8
;
9
; This source file is free software: you can redistribute it and/or modify
10
; it under the terms of the GNU Lesser General Public License as published
11
; by the Free Software Foundation, either version 3 of the License, or
12
; (at your option) any later version.
13
;
14
; This source file is distributed in the hope that it will be useful,
15
; but WITHOUT ANY WARRANTY; without even the implied warranty of
16
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
; GNU General Public License for more details.
18
;
19
; You should have received a copy of the GNU General Public License
20
; along with this program.  If not, see .
21
;
22
;
23
; ============================================================================
24
 
25
 
26
DBG_DS          = $5000
27
DBG_ATTR        = %000011000_111111110_0000000000
28
 
29
                bss
30
                org             $1000
31
DBGBuf          fill.b  84,0
32
DBGBufndx       db              0
33
 
34
                code
35
                org             $FFFFC800
36
 
37
;------------------------------------------------------------------------------
38
; r2 = text output column
39
; r6 = text output row
40
; r5 = disassembly address
41
;------------------------------------------------------------------------------
42
 
43
public Debugger:
44
                sys             #190                            ; save context
45
                ldi             sp,#$2bf8
46
                addui   sp,sp,#-24
47
                sws             c1,[sp]
48
                sws             ds,8[sp]
49
                sws             ds.lmt,16[sp]
50
                ldis    ds,#DBG_DS
51
                ldis    ds.lmt,#$8000
52
                sws             ds,zs:IOFocusNdx_
53
                sync
54
                bsr             KeybdClearBuf
55
                bsr             VideoInit2
56
                bsr             VBClearScreen
57
                mov             r1,r0                           ; row = 0
58
                mov             r2,r0                           ; col = 0
59
                ldi             r6,#2                           ; set cursor pos
60
                sys             #10                                     ; call video BIOS
61
;               bsr             DBGRamTest
62
                lla             r1,cs:msgDebugger       ; convert address to linear
63
                ldi             r6,#$14                         ; Try display string
64
                sys             #10                                     ; call video BIOS
65
                mov             r6,r0
66
                mov             r2,r0
67
                ldi             r5,#$FFFF8000
68
                bsr             DBGDisassem20
69
;               br              Debugger_exit
70
 
71
promptAgain:
72
                ; Clear input buffer
73
                sb              r0,DBGBufndx
74
                ldis    lc,#$14                 ; (21-1)*4
75
                ldi             r1,#DBGBuf
76
                ldi             r2,#0                   ;
77
                stset.hi        r2,[r1]         ; clear the buffer
78
 
79
                ldi             r6,#30                  ; move cursor pos to row 30
80
                bsr             DBGPrompt
81
 
82
                ; Get character loop
83
.0001:
84
                bsr             KeybdGetCharWait
85
                cmpi    p0,r1,#CR
86
p0.eq   br              .processInput
87
                cmpi    p0,r1,#_BS
88
p0.eq   br              .backspace
89
                cmpi    p0,r1,#' '
90
p0.ltu  br              .0001
91
                ; some other character, store in buffer if it will fit
92
                lbu             r3,DBGBufndx
93
                cmpi    p3,r3,#80               ; max 80 chars
94
p3.ltu  bsr             DBGDispChar
95
p3.ltu  sb              r1,DBGBuf[r3]
96
p3.ltu  addui   r3,r3,#1
97
p3.ltu  sb              r3,DBGBufndx
98
                br              .0001
99
.backspace:
100
                lbu             r1,DBGBufndx
101
                tst             p0,r1                   ; is is even possible to backspace ?
102
p0.eq   br              .0001
103
                ldi             r7,#$80
104
                subu    r7,r7,r1
105
                addui   r7,r7,#-1               ; loop count is one less
106
                mtspr   lc,r7
107
                addui   r1,r1,#DBGBuf
108
                mov             r4,r1
109
                addui   r1,r1,#-1
110
                mov             r3,r0
111
                stmov.bi        [r4],[r1],r3
112
 
113
                br              .0001
114
.processInput:
115
                mov             r4,r0
116
.0002:
117
                lbu             r1,DBGBuf[r4]
118
                tst             p0,r1
119
p0.eq   br              promptAgain
120
                cmpi    p0,r1,#' '
121
p0.leu  addui   r4,r4,#1
122
p0.leu  br              .0002
123
                cmpi    p0,r1,#'D'
124
p0.eq   addui   r4,r4,#1
125
p0.eq   br              DoDisassem
126
                cmpi    p0,r1,#'M'
127
p0.eq   br              DBGDumpMem
128
                cmpi    p0,r1,#'x'
129
p0.eq   br              Debugger_exit
130
                br              promptAgain
131
Debugger_exit:
132
                lws             c1,[sp]
133
                lws             ds,8[sp]
134
                lws             ds.lmt,16[sp]
135
                sws             ds,zs:IOFocusNdx_
136
                sys             #191                    ; restore context
137
                rts
138
endpublic
139
 
140
;------------------------------------------------------------------------------
141
;------------------------------------------------------------------------------
142
 
143
DoDisassem:
144
                bsr             DBGGetHexNumber
145
                tst             p0,r8
146
p0.eq   br              promptAgain
147
                mov             r5,r1
148
                bsr             VBClearScreen2
149
                bsr             DBGDisassem20
150
                br              promptAgain
151
 
152
;------------------------------------------------------------------------------
153
; Dump memory bytes
154
; M 
155
;------------------------------------------------------------------------------
156
 
157
DBGDumpMem:
158
                addui   r4,r4,#1                        ; advance a character past 'M'
159
                bsr             DBGGetHexNumber
160
                mov             r12,r1
161
                tst             p0,r8
162
p0.eq   jmp             promptAgain
163
                bsr             VBClearScreen2
164
                addui   r13,r12,#200
165
                ldi             r6,#2
166
                mov             r2,r0
167
.0002:
168
                mov             r14,r0
169
                ldi             r1,#'>'
170
                bsr             DBGDispChar
171
                mov             r4,r12
172
                bsr             DBGDisplayHalf
173
.0001:
174
                bsr             space1
175
                lbu             r4,zs:[r12+r14]
176
                bsr             DBGDisplayByte
177
                addui   r14,r14,#1
178
                cmpi    p0,r14,#8
179
p0.ltu  br              .0001
180
                bsr             space1
181
                mov             r14,r0
182
                bsr             ReverseVideo            ; reverse video attribute
183
.0003:
184
                lbu             r1,zs:[r12+r14]
185
                cmpi    p0,r1,#' '
186
p0.ltu  ldi             r1,#'.'
187
                bsr             DBGDispChar
188
                addui   r14,r14,#1
189
                cmpi    p0,r14,#8
190
p0.ltu  br              .0003
191
                bsr             ReverseVideo            ; put video back to normal
192
                addui   r6,r6,#1
193
                addu    r12,r12,r14
194
                cmp             p0,r12,r13
195
p0.ltu  br              .0002
196
                jmp             promptAgain
197
 
198
;------------------------------------------------------------------------------
199
; DBGGetHexNumber:
200
;       Get a hexi-decimal number from the input buffer.
201
;
202
; Parameters:
203
;       r4 = text pointer (updated)
204
; Returns:
205
;       r1 = number
206
;   r8 = number of digits
207
;------------------------------------------------------------------------------
208
 
209
DBGGetHexNumber:
210
                addui   sp,sp,#-8
211
                sws             c1,[sp]
212
                ldis    lc,#80                  ; max 80 chars
213
                mov             r7,r0                   ; working accum.
214
                mov             r8,r0                   ; number of digits
215
.0003:
216
                lbu             r1,[r4]                 ; skip leading spaces
217
                cmpi    p0,r1,#' '
218
p0.leu  addui   r4,r4,#1
219
p0.leu  br              .0003
220
.0002:
221
                lbu             r1,[r4]
222
                bsr             DBGCharToHex
223
                tst             p0,r3
224
p0.eq   br              .0001
225
                shli    r7,r7,#4
226
                or              r7,r7,r1
227
                addui   r4,r4,#1
228
                addui   r8,r8,#1
229
                loop    .0002
230
.0001:
231
                mov             r1,r7
232
                lws             c1,[sp]
233
                addui   sp,sp,#8
234
                rts
235
 
236
;------------------------------------------------------------------------------
237
; DBGCharToHex:
238
;       Convert a single ascii character to hex nybble.
239
; Parameters:
240
;       r1 = ascii character to convert
241
; Returns:
242
;       r1 = binary nybble
243
;       r3 = 1 if conversion successful, 0 otherwise
244
;------------------------------------------------------------------------------
245
 
246
DBGCharToHex:
247
                cmpi    p0,r1,#'0'
248
p0.ltu  br              .0004
249
                cmpi    p0,r1,#'9'
250
p0.gtu  br              .0001
251
                addui   r1,r1,#-'0'
252
                ldi             r3,#1
253
                rts
254
.0001:
255
                cmpi    p0,r1,#'A'
256
p0.ltu  br              .0004
257
                cmpi    p0,r1,#'F'
258
p0.gtu  br              .0003
259
                subui   r1,r1,#'A'-10
260
                ldi             r3,#1
261
                rts
262
.0003:
263
                cmpi    p0,r1,#'a'
264
p0.ltu  br              .0004
265
                cmpi    p0,r1,#'f'
266
p0.gtu  br              .0004
267
                subui   r1,r1,#'a'-10
268
                ldi             r3,#1
269
                rts
270
.0004:
271
                mov             r3,r0
272
.exit:
273
                rts
274
 
275
;------------------------------------------------------------------------------
276
;------------------------------------------------------------------------------
277
 
278
public DebugIRQ:
279
                sw              sp,reg_save+8*27
280
                ldi             sp,#$2bf8
281
                addui   sp,sp,#-104
282
                sws             c1,[sp]
283
                sws             ds,8[sp]
284
                sws             ds.lmt,16[sp]
285
                sw              r1,24[sp]
286
                sw              r2,32[sp]
287
                sw              r3,40[sp]
288
                sw              r4,48[sp]
289
                sw              r5,56[sp]
290
                sw              r6,64[sp]
291
                sw              r7,72[sp]
292
                sw              r8,80[sp]
293
                sw              r9,88[sp]
294
                sw              r10,96[sp]
295
 
296
                ldis    ds,#DBG_DS
297
                ldis    ds.lmt,#$8000
298
                sync
299
                bsr             VBClearScreen2
300
                mov             r2,r0
301
                mov             r6,r0
302
                ldi             r1,#msgDebugger
303
                bsr             DBGDispString
304
                mfspr   r5,dpc
305
                bsr             DBGDisassem20
306
 
307
                lws             c1,[sp]
308
                lws             ds,8[sp]
309
                lws             ds.lmt,16[sp]
310
                lw              r1,24[sp]
311
                lw              r2,32[sp]
312
                lw              r3,40[sp]
313
                lw              r4,48[sp]
314
                lw              r5,56[sp]
315
                lw              r6,64[sp]
316
                lw              r7,72[sp]
317
                lw              r8,80[sp]
318
                lw              r9,88[sp]
319
                lw              r10,96[sp]
320
                lw              sp,reg_save+8*27
321
                rtd
322
endpublic
323
 
324
;------------------------------------------------------------------------------
325
; Disassemble 20 lines of code.
326
;------------------------------------------------------------------------------
327
 
328
DBGDisassem20:
329
                addui   sp,sp,#-8
330
                sws             c1,[sp]
331
                ldis    lc,#19
332
                ldi             r6,#3
333
.0001:
334
                bsr             Disassem
335
                addu    r5,r5,r10
336
                addui   r6,r6,#1
337
                loop    .0001
338
                lws             c1,[sp]
339
                addui   sp,sp,#8
340
                rts
341
 
342
;------------------------------------------------------------------------------
343
;------------------------------------------------------------------------------
344
 
345
DBGPrompt:
346
                addui   sp,sp,#-8
347
                sws             c1,[sp]
348
                mov             r2,r0
349
                ldi             r1,#'D'
350
                bsr             DBGDispChar
351
                ldi             r1,#'B'
352
                bsr             DBGDispChar
353
                ldi             r1,#'G'
354
                bsr             DBGDispChar
355
                ldi             r1,#'>'
356
                bsr             DBGDispChar
357
                lws             c1,[sp]
358
                addui   sp,sp,#8
359
                rts
360
 
361
;------------------------------------------------------------------------------
362
;------------------------------------------------------------------------------
363
 
364
Disassem:
365
                addui   sp,sp,#-16
366
                sws             c1,[sp]
367
                sws             c2,8[sp]
368
                ldi             r2,#1                           ; column one
369
                bsr             DisplayAddr
370
                bsr             DisplayBytes
371
                ldi             r2,#38                          ; tab to column 38
372
                bsr             DBGDisplayPred
373
                ldi             r2,#46                          ; tab to column 46
374
                mov             r3,r0
375
                lbu             r1,zs:[r5]
376
                cmpi    p0,r1,#$00
377
p0.eq   ldi             r3,#mne_brk
378
                cmpi    p0,r1,#$10
379
p0.eq   ldi             r3,#mne_nop
380
                cmpi    p0,r1,#$11
381
p0.eq   ldi             r3,#mne_rts
382
                cmpi    p0,r1,#$20
383
p0.eq   ldi             r3,#mne_imm
384
                cmpi    p0,r1,#$30
385
p0.eq   ldi             r3,#mne_imm
386
                cmpi    p0,r1,#$40
387
p0.eq   ldi             r3,#mne_imm
388
                cmpi    p0,r1,#$50
389
p0.eq   ldi             r3,#mne_imm
390
                cmpi    p0,r1,#$60
391
p0.eq   ldi             r3,#mne_imm
392
                cmpi    p0,r1,#$70
393
p0.eq   ldi             r3,#mne_imm
394
                cmpi    p0,r1,#$80
395
p0.eq   ldi             r3,#mne_imm
396
                tst             p0,r3
397
p0.ne   bsr             DBGDisplayMne
398
p0.eq   br              .0001
399
                br              .exit
400
.0001:
401
                lbu             r1,zs:1[r5]             ; get the opcode
402
                shli    r1,r1,#1
403
                lcu             r1,cs:DBGInsnMne[r1]
404
                cmpi    p0,r1,#$FFF0
405
p0.geu  br              .0002
406
.dispMne:
407
                ori             r3,r1,#Debugger & $FFFF0000	; set high order address bits
408
                bsr             DBGDisplayMne
409
                br              .dispOper
410
.0002:
411
                andi    r1,r1,#15
412
                lcu             r3,cs:DBGInsnMneT[r1]
413
                ori             r3,r3,#Debugger & $FFFF0000
414
                bsr             DBGGetFunc
415
                lcu             r3,cs:[r3+r1*2]
416
                br              .dispMne
417
.dispOper:
418
                lbu             r1,zs:1[r5]
419
                lbu             r1,cs:DBGOperFmt[r1]
420
                jci             c1,cs:DBGOperFmtT[r1]
421
                ldi             r1,#48
422
                sc              r1,hs:LEDS
423
;               lcu             r1,cs:DBGOperFmtT[r1]
424
;               ori             r1,r1,#Debugger & $FFFF0000
425
;               mtspr   c2,r1
426
;               jsr             [c2]
427
.exit:
428
                lws             c1,[sp]
429
                lws             c2,8[sp]
430
                addui   sp,sp,#16
431
                rts
432
 
433
;------------------------------------------------------------------------------
434
; Display the disassembly address.
435
;------------------------------------------------------------------------------
436
 
437
DisplayAddr:
438
                addui   sp,sp,#-8
439
                sws             c1,[sp]
440
                mov             r4,r5
441
                bsr             DBGDisplayHalf
442
                bsr             space3
443
                lws             c1,[sp]
444
                addui   sp,sp,#8
445
                rts
446
space1:
447
                addui   sp,sp,#-8
448
                sws             c1,[sp]
449
                ldi             r1,#' '
450
                bsr             DBGDispChar
451
                lws             c1,[sp]
452
                addui   sp,sp,#8
453
                rts
454
space3:
455
                addui   sp,sp,#-8
456
                sws             c1,[sp]
457
                bsr             space1
458
                bsr             space1
459
                bsr             space1
460
                lws             c1,[sp]
461
                addui   sp,sp,#8
462
                rts
463
 
464
;------------------------------------------------------------------------------
465
;------------------------------------------------------------------------------
466
 
467
DBGDisplayHalf:
468
                addui   sp,sp,#-8
469
                sws             c1,[sp]
470
                rori    r4,r4,#16
471
                bsr             DBGDisplayCharr
472
                roli    r4,r4,#16
473
                bsr             DBGDisplayCharr
474
                lws             c1,[sp]
475
                addui   sp,sp,#8
476
                rts
477
 
478
DBGDisplayCharr:
479
                addui   sp,sp,#-8
480
                sws             c1,[sp]
481
                rori    r4,r4,#8
482
                bsr             DBGDisplayByte
483
                roli    r4,r4,#8
484
                bsr             DBGDisplayByte
485
                lws             c1,[sp]
486
                addui   sp,sp,#8
487
                rts
488
 
489
DBGDisplayByte:
490
                addui   sp,sp,#-8
491
                sws             c1,[sp]
492
                rori    r4,r4,#4
493
                bsr             DBGDisplayNybble
494
                roli    r4,r4,#4
495
                bsr             DBGDisplayNybble
496
                lws             c1,[sp]
497
                addui   sp,sp,#8
498
                rts
499
 
500
DBGDisplayNybble:
501
                addui   sp,sp,#-8
502
                sws             c1,[sp]
503
                andi    r1,r4,#15
504
                cmpi    p0,r1,#9
505
p0.gtu  addui   r1,r1,#7
506
                addui   r1,r1,#'0'
507
                bsr             DBGDispChar
508
                lws             c1,[sp]
509
                addui   sp,sp,#8
510
                rts
511
 
512
;------------------------------------------------------------------------------
513
; DBGDispChar:
514
;
515
; Display a character on the debug screen.
516
;
517
; Parameters:
518
;       r1 = character to display
519
;       r2 = text column
520
;       r6 = text row
521
; Returns:
522
;       r2 incremented
523
;------------------------------------------------------------------------------
524
 
525
DBGDispChar:
526
                addui   sp,sp,#-16
527
                sws             c1,[sp]                         ; save return address
528
                sw              r7,8[sp]                        ; save r7 work register
529
                andi    r1,r1,#$7F                      ; make sure in range
530
                bsr             VBAsciiToScreen         ; convert to screen char
531
                ori             r1,r1,#DBG_ATTR         ; add in attribute
532
                lcu             r7,Textcols                     ; figure out memory index
533
                mulu    r7,r6,r7                        ; row * num cols
534
                _4addui r7,r7,#$10000   ; + text base + (row * num cols) * 4
535
                _4addu  r7,r2,r7                        ; + column * 4
536
                sh              r1,hs:[r7]                      ; store the char
537
                addui   r2,r2,#1                        ; increment text position
538
                lws             c1,[sp]                         ; restore return address
539
                lw              r7,8[sp]
540
                addui   sp,sp,#16
541
                rts
542
 
543
;------------------------------------------------------------------------------
544
; Display a string of text on the debug screen.
545
;------------------------------------------------------------------------------
546
 
547
DBGDispString:
548
                addui   sp,sp,#-16
549
                sws             c1,[sp]
550
                sw              r7,8[sp]
551
                mov             r7,r1
552
.0001:
553
                lbu             r1,zs:[r7]
554
                tst             p0,r1
555
p0.eq   br              .0002
556
                bsr             DBGDispChar
557
                addui   r7,r7,#1
558
                br              .0001
559
.0002:
560
                lws             c1,[sp]
561
                lw              r7,8[sp]
562
                addui   sp,sp,#16
563
                rts
564
 
565
;------------------------------------------------------------------------------
566
; Get the length of an instruction.
567
;------------------------------------------------------------------------------
568
 
569
public DBGGetInsnLength:
570
                addui   r31,r31,#-8
571
                sws             c1,[r31]
572
                lbu             r1,zs:[r5]
573
                ; Test for special predicate values which are one byte long.
574
                cmpi    p0,r1,#$00              ; BRK
575
p0.eq   ldi             r1,#1
576
p0.eq   br              .0001
577
                cmpi    p0,r1,#$10              ; NOP
578
p0.eq   ldi             r1,#1
579
p0.eq   br              .0001
580
                cmpi    p0,r1,#$11              ; RTS
581
p0.eq   ldi             r1,#1
582
p0.eq   br              .0001
583
                ; Test for special immediate predicates these vary in length.
584
                cmpi    p0,r1,#$20
585
p0.eq   ldi             r1,#2
586
p0.eq   br              .0001
587
                cmpi    p0,r1,#$30
588
p0.eq   ldi             r1,#3
589
p0.eq   br              .0001
590
                cmpi    p0,r1,#$40
591
p0.eq   ldi             r1,#4
592
p0.eq   br              .0001
593
                cmpi    p0,r1,#$50
594
p0.eq   ldi             r1,#5
595
p0.eq   br              .0001
596
                cmpi    p0,r1,#$60
597
p0.eq   ldi             r1,#6
598
p0.eq   br              .0001
599
                cmpi    p0,r1,#$70
600
p0.eq   ldi             r1,#7
601
p0.eq   br              .0001
602
                cmpi    p0,r1,#$80
603
p0.eq   ldi             r1,#8
604
p0.ne   lbu             r1,zs:1[r5]
605
p0.ne   lbu             r1,cs:DBGInsnLength[r1]
606
.0001:
607
                lws             c1,[r31]
608
                addui   r31,r31,#8
609
                rts
610
endpublic
611
 
612
;------------------------------------------------------------------------------
613
; Display the bytes associated with an instruction. There may be up to eight
614
; bytes displayed.
615
;       r7 = offset from r5 the dump address
616
;------------------------------------------------------------------------------
617
 
618
DisplayBytes:
619
                addui   sp,sp,#-24
620
                sws             c1,[sp]
621
                sws             lc,8[sp]
622
                sw              r7,16[sp]
623
                sei
624
                ldi             r31,#INT_STACK
625
                bsr             DBGGetInsnLength
626
                mov             r10,r1
627
                cli
628
                addui   r1,r1,#-1               ; loop count is one less
629
                mtspr   lc,r1
630
                mov             r7,r0
631
.next:
632
                lbu             r4,zs:[r5+r7]
633
                bsr             DBGDisplayByte
634
                bsr             space1                  ; skip a space
635
                addui   r7,r7,#1                ; increment offset to next byte
636
                loop    .next
637
                lws             c1,[sp]
638
                lws             lc,8[sp]
639
                lw              r7,16[sp]
640
                addui   sp,sp,#24
641
                rts
642
 
643
;------------------------------------------------------------------------------
644
; Display a predicate.
645
;
646
; The always true predicate and special predicate values don't display.
647
;------------------------------------------------------------------------------
648
 
649
DBGDisplayPred:
650
                addui   sp,sp,#-8
651
                sws             c1,[sp]
652
                lbu             r1,zs:[r5]
653
                cmpi    p0,r1,#$00              ; brk special
654
p0.eq   br              .noDisp
655
                cmpi    p0,r1,#$01              ; always true predicate doesn't display
656
p0.eq   br              .noDisp
657
                cmpi    p0,r1,#$11              ; rts special
658
p0.eq   br              .noDisp
659
                cmpi    p0,r1,#$10              ; nop special
660
p0.eq   br              .noDisp
661
                cmpi    p0,r1,#$20
662
p0.eq   br              .noDisp
663
                cmpi    p0,r1,#$30
664
p0.eq   br              .noDisp
665
                cmpi    p0,r1,#$40
666
p0.eq   br              .noDisp
667
                cmpi    p0,r1,#$50
668
p0.eq   br              .noDisp
669
                cmpi    p0,r1,#$60
670
p0.eq   br              .noDisp
671
                cmpi    p0,r1,#$70
672
p0.eq   br              .noDisp
673
                cmpi    p0,r1,#$80
674
p0.eq   br              .noDisp
675
                ldi             r1,#'p'
676
                bsr             DBGDispChar
677
                lbu             r4,zs:[r5]
678
                shrui   r4,r4,#4
679
                bsr             DBGDisplayNybble
680
                ldi             r1,#'.'
681
                bsr             DBGDispChar
682
                lbu             r1,zs:[r5]
683
                bsr             DBGDispCond
684
                br              .exit
685
.noDisp:
686
                addui   r2,r2,#7
687
.exit
688
                lws             c1,[sp]
689
                addui   sp,sp,#8
690
                rts
691
 
692
;------------------------------------------------------------------------------
693
; Display the condition portion of the predicate.
694
;------------------------------------------------------------------------------
695
 
696
DBGDispCond:
697
                addui   sp,sp,#-8
698
                sws             c1,[sp]
699
                andi    r7,r1,#15
700
                addu    r7,r7,r7
701
                addu    r7,r7,r1
702
                lbu             r1,cs:DBGPredCons[r7]
703
                bsr             DBGDispChar
704
                lbu             r1,cs:DBGPredCons+1[r7]
705
                bsr             DBGDispChar
706
                lbu             r1,cs:DBGPredCons+2[r7]
707
                bsr             DBGDispChar
708
                lws             c1,[sp]
709
                addui   sp,sp,#8
710
                rts
711
 
712
;------------------------------------------------------------------------------
713
; Display a mnemonic.
714
; Parameters:
715
;       r3 = pointer to mnemonic string
716
;------------------------------------------------------------------------------
717
 
718
DBGDisplayMne:
719
                addui   sp,sp,#-8
720
                sws             c1,[sp]
721
                bsr             space1
722
                ; Mnemonics are always at least 2 chars
723
                lbu             r1,cs:[r3]
724
                bsr             DBGDispChar
725
                ; second char
726
                lbu             r1,cs:1[r3]
727
                biti    p1,r1,#$80                      ; test high bit
728
                bsr             DBGDispChar
729
p1.ne   br              .exit
730
                ; third char
731
                lbu             r1,cs:2[r3]
732
                biti    p1,r1,#$80                      ; test high bit
733
                bsr             DBGDispChar
734
p1.ne   br              .exit
735
                ; fourth char
736
                lbu             r1,cs:3[r3]
737
                biti    p1,r1,#$80                      ; test high bit
738
                bsr             DBGDispChar
739
p1.ne   br              .exit
740
                ; fifth char
741
                lbu             r1,cs:4[r3]
742
                bsr             DBGDispChar
743
.exit:
744
                addui   r2,r2,#1                        ; 1 space
745
                lws             c1,[sp]
746
                addui   sp,sp,#8
747
                rts
748
 
749
;------------------------------------------------------------------------------
750
; Display a register
751
;------------------------------------------------------------------------------
752
 
753
DBGDispReg:
754
                addui   sp,sp,#-16
755
                sws             c1,[sp]
756
                sw              r7,8[sp]
757
                mov             r7,r1
758
                ldi             r1,#'r'
759
DBGDispBx1:
760
                bsr             DBGDispChar
761
                cmpi    p0,r7,#10
762
p0.geu  divui   r1,r7,#10
763
p0.geu  addui   r1,r1,#'0'
764
p0.geu  bsr             DBGDispChar
765
                modui   r1,r7,#10
766
                addui   r1,r1,#'0'
767
                bsr             DBGDispChar
768
                lws             c1,[sp]
769
                lw              r7,8[sp]
770
                addui   sp,sp,#16
771
                rts
772
 
773
;------------------------------------------------------------------------------
774
; Display a bit number
775
;------------------------------------------------------------------------------
776
 
777
DBGDispBReg:
778
                addui   sp,sp,#-16
779
                sws             c1,[sp]
780
                sw              r7,8[sp]
781
                mov             r7,r1
782
                ldi             r1,#'b'
783
                br              DBGDispBx1
784
 
785
;------------------------------------------------------------------------------
786
; Display a special purpose register
787
;------------------------------------------------------------------------------
788
 
789
DBGDispSpr:
790
                addui   sp,sp,#-16
791
                sws             c1,[sp]
792
                sw              r7,8[sp]
793
                addu    r7,r1,r1
794
                addu    r7,r7,r1                        ; r7 = r1 * 3
795
                lbu             r1,cs:DBGSpr[r7]
796
                bsr             DBGDispChar
797
                lbu             r1,cs:DBGSpr+1[r7]
798
                bsr             DBGDispChar
799
                lbu             r1,cs:DBGSpr+2[r7]
800
                cmpi    p0,r1,#' '
801
p0.ne   bsr             DBGDispChar
802
                lws             c1,[sp]
803
                lw              r7,8[sp]
804
                addui   sp,sp,#16
805
                rts
806
 
807
;------------------------------------------------------------------------------
808
;------------------------------------------------------------------------------
809
 
810
DBGComma:
811
                addui   sp,sp,#-8
812
                sws             c1,[sp]
813
                ldi             r1,#','
814
                bsr             DBGDispChar
815
                lws             c1,[sp]
816
                addui   sp,sp,#8
817
                rts
818
 
819
;------------------------------------------------------------------------------
820
; Display registers for TST instruction.
821
;------------------------------------------------------------------------------
822
 
823
DBGDispTstregs:
824
                addui   sp,sp,#-8
825
                sws             c1,[sp]
826
                ldi             r2,#54                  ; tab out to column 54
827
                lbu             r1,zs:1[r5]
828
                andi    r1,r1,#15
829
                bsr             DBGDispSpr
830
                bsr             DBGComma
831
                lbu             r1,zs:2[r5]
832
                andi    r1,r1,#$3f
833
                bsr             DBGDispReg
834
                lws             c1,[sp]
835
                addui   sp,sp,#8
836
                rts
837
 
838
DBGDispCmpregs:
839
                addui   sp,sp,#-8
840
                sws             c1,[sp]
841
                ldi             r2,#54                  ; tab out to column 54
842
                lbu             r1,zs:1[r5]
843
                andi    r1,r1,#15
844
                bsr             DBGDispSpr
845
                bsr             DBGComma
846
                lbu             r1,zs:2[r5]
847
                andi    r1,r1,#$3f
848
                bsr             DBGDispReg
849
                bsr             DBGComma
850
                lbu             r1,zs:2[r5]
851
                shrui   r1,r1,#6
852
                lbu             r7,zs:3[r5]
853
                andi    r7,r7,#15
854
                shli    r7,r7,#2
855
                or              r1,r7,r1
856
                bsr             DBGDispReg
857
                lws             c1,[sp]
858
                addui   sp,sp,#8
859
                rts
860
 
861
DBGDispBrDisp:
862
                addui   sp,sp,#-8
863
                sws             c1,[sp]
864
                ldi             r2,#54                  ; tab out to column 54
865
                lbu             r1,zs:1[r5]
866
                lbu             r7,zs:2[r5]
867
                andi    r1,r1,#15
868
                shli    r7,r7,#4
869
                or              r1,r7,r1
870
                addui   r1,r1,#3                ; instruction size
871
                addu    r4,r1,r5                ; instruction address
872
                ldi             r1,#'$'
873
                bsr             DBGDispChar
874
                bsr             DBGDisplayHalf
875
                lws             c1,[sp]
876
                addui   sp,sp,#8
877
                rts
878
 
879
DBGDispCmpimm:
880
                addui   sp,sp,#-8
881
                sws             c1,[sp]
882
                ldi             r2,#54                  ; tab out to column 54
883
                lbu             r1,zs:1[r5]
884
                andi    r1,r1,#15
885
                bsr             DBGDispSpr
886
                bsr             DBGComma
887
                lbu             r1,zs:2[r5]
888
                andi    r1,r1,#$3f
889
                bsr             DBGDispReg
890
                bsr             DBGComma
891
                lbu             r1,zs:2[r5]
892
                shrui   r1,r1,#6
893
                lbu             r7,zs:3[r5]
894
                shli    r7,r7,#2
895
                or              r4,r7,r1
896
                ldi             r1,#'#'
897
                bsr             DBGDispChar
898
                ldi             r1,#'$'
899
                bsr             DBGDispChar
900
                bsr             DBGDisplayHalf
901
                lws             c1,[sp]
902
                addui   sp,sp,#8
903
                rts
904
 
905
; Used by mtspr
906
DBGDispSprRx:
907
                addui   sp,sp,#-16
908
                sws             c1,[sp]
909
                sw              r7,8[sp]
910
                ldi             r2,#54                  ; tab out to column 54
911
                lbu             r1,zs:2[r5]
912
                lbu             r7,zs:3[r5]
913
                shrui   r1,r1,#6
914
                andi    r7,r7,#15
915
                shli    r7,r7,#2
916
                or              r1,r7,r1
917
                bsr             DBGDispSpr
918
                bsr             DBGComma
919
                lbu             r1,zs:2[r5]
920
                andi    r1,r1,#63
921
                bsr             DBGDispReg
922
                lws             c1,[sp]
923
                lw              r7,8[sp]
924
                addui   sp,sp,#16
925
                rts
926
 
927
; Format #4
928
;
929
DBGDispRxRxRx:
930
                addui   sp,sp,#-16
931
                sws             c1,[sp]
932
                sw              r7,8[sp]
933
                ldi             r2,#54                  ; tab out to column 54
934
                lbu             r1,zs:3[r5]
935
                shrui   r1,r1,#4
936
                lbu             r7,zs:4[r5]
937
                andi    r7,r7,#3
938
                shli    r7,r7,#4
939
                or              r1,r7,r1
940
                bsr             DBGDispReg
941
                bsr             DBGComma
942
                lbu             r1,zs:2[r5]
943
                andi    r1,r1,#63
944
                bsr             DBGDispReg
945
                bsr             DBGComma
946
                lbu             r1,zs:2[r5]
947
                shrui   r1,r1,#6
948
                lbu             r7,zs:3[r5]
949
                andi    r7,r7,#15
950
                shli    r7,r7,#2
951
                or              r1,r7,r1
952
                bsr             DBGDispReg
953
                lws             c1,[sp]
954
                lw              r7,8[sp]
955
                addui   sp,sp,#16
956
                rts
957
 
958
; Format #5
959
;
960
DBGDispRxRx:
961
                addui   sp,sp,#-16
962
                sws             c1,[sp]
963
                sw              r7,8[sp]
964
                ldi             r2,#54                  ; tab out to column 54
965
                lbu             r1,zs:2[r5]
966
                shrui   r1,r1,#6
967
                lbu             r7,zs:3[r5]
968
                andi    r7,r7,#15
969
                shli    r7,r7,#2
970
                or              r1,r7,r1
971
                bsr             DBGDispReg
972
                bsr             DBGComma
973
                lbu             r1,zs:2[r5]
974
                andi    r1,r1,#63
975
                bsr             DBGDispReg
976
                lws             c1,[sp]
977
                lw              r7,8[sp]
978
                addui   sp,sp,#16
979
                rts
980
 
981
; Format #6
982
;
983
DBGDispPxPxPx:
984
                addui   sp,sp,#-16
985
                sws             c1,[sp]
986
                sw              r7,8[sp]
987
                ldi             r2,#54                  ; tab out to column 54
988
                lbu             r1,zs:3[r5]
989
                shrui   r1,r1,#4
990
                lbu             r7,zs:4[r5]
991
                andi    r7,r7,#3
992
                shli    r7,r7,#4
993
                or              r1,r7,r1
994
                bsr             DBGDispBReg
995
                bsr             DBGComma
996
                lbu             r1,zs:2[r5]
997
                andi    r1,r1,#63
998
                bsr             DBGDispBReg
999
                bsr             DBGComma
1000
                lbu             r1,zs:2[r5]
1001
                shrui   r1,r1,#6
1002
                lbu             r7,zs:3[r5]
1003
                andi    r7,r7,#15
1004
                shli    r7,r7,#2
1005
                or              r1,r7,r1
1006
                bsr             DBGDispBReg
1007
                lws             c1,[sp]
1008
                lw              r7,8[sp]
1009
                addui   sp,sp,#16
1010
                rts
1011
 
1012
; Format #7
1013
;
1014
DBGDispNone:
1015
                rts
1016
 
1017
; Format #8 (biti)
1018
;
1019
DBGDispPxRxImm:
1020
                addui   sp,sp,#-16
1021
                sws             c1,[sp]
1022
                ldi             r2,#54                  ; tab out to column 54
1023
                lbu             r1,zs:2[r5]
1024
                shrui   r1,r1,#6
1025
                lbu             r7,zs:3[r5]
1026
                andi    r7,r7,#3
1027
                _4addu  r1,r7,r1
1028
                bsr             DBGDispSpr
1029
                bsr             DBGComma
1030
                lbu             r1,zs:2[r5]
1031
                andi    r1,r1,#63
1032
                bsr             DBGDispReg
1033
                bsr             DBGComma
1034
                lbu             r1,zs:3[r5]
1035
                shrui   r1,r1,#4
1036
                lbu             r7,zs:4[r5]
1037
                _16addu r1,r7,r1
1038
                bsr             DBGDispImm
1039
                lws             c1,[sp]
1040
                addui   sp,sp,#16
1041
                rts
1042
 
1043
; Format #9 (adduis)
1044
;
1045
DBGDispRxImm:
1046
                addui   sp,sp,#-8
1047
                sws             c1,[sp]
1048
                lbu             r1,zs:2[r5]
1049
                andi    r1,r1,#63
1050
                bsr             DBGDispReg
1051
                bsr             DBGComma
1052
                lbu             r1,zs:2[r2]
1053
                shrui   r1,r1,#6
1054
                lbu             r7,zs:3[r2]
1055
                _4addu  r1,r7,r1
1056
                bsr             DBGDispImm
1057
                lws             c1,[sp]
1058
                addui   sp,sp,#8
1059
                rts
1060
 
1061
;------------------------------------------------------------------------------
1062
; Display an immediate value.
1063
;------------------------------------------------------------------------------
1064
 
1065
DBGDispImm:
1066
                addui   sp,sp,#-16
1067
                sws             c1,[sp]
1068
                sw              r4,8[sp]
1069
                mov             r4,r1
1070
                ldi             r1,#'#'
1071
                bsr             DBGDispChar
1072
                ldi             r1,#'$'
1073
                bsr             DBGDispChar
1074
                cmpi    p0,r4,#$FFFF
1075
p0.gtu  bsr             DBGDisplayHalf
1076
p0.gtu  br              .exit
1077
                cmpi    p0,r4,#$FF
1078
p0.gtu  bsr             DBGDisplayCharr
1079
p0.gtu  br              .exit
1080
                bsr             DBGDisplayByte
1081
.exit:
1082
                lw              c1,[sp]
1083
                lw              r4,8[sp]
1084
                addui   sp,sp,#16
1085
                rts
1086
 
1087
;------------------------------------------------------------------------------
1088
; DBGGetFunc:
1089
;    Get the function code bits from the instruction. These come from one of
1090
; four different locations depending on the opcode.
1091
;
1092
; Parameters:
1093
;       r1 = opcode group (0 to 15)
1094
; Returns:
1095
;       r1 = function code
1096
;------------------------------------------------------------------------------
1097
 
1098
DBGGetFunc:
1099
                jci             c0,cs:DBGFuncT[r1]
1100
gf0:
1101
gf2:
1102
gf3:
1103
gf4:
1104
gf6:
1105
gfB:
1106
                lbu             r1,zs:4[r5]
1107
                shrui   r1,r1,#2
1108
                rts
1109
gf1:
1110
gf5:
1111
gf7:
1112
gf8:
1113
                lbu             r1,zs:3[r5]
1114
                shrui   r1,r1,#4
1115
                rts
1116
gf9:
1117
                lbu             r1,zs:5[r5]
1118
                andi    r1,r1,#15
1119
                rts
1120
gfA:
1121
                lbu             r1,zs:2[r5]
1122
                andi    r1,r1,#15
1123
                rts
1124
 
1125
;------------------------------------------------------------------------------
1126
; Checker-board RAM testing routine.
1127
;
1128
; Ram is tested from $6000 to $7FFFFFF. The first 24k of RAM is not tested,
1129
; as 16k underlays the scratchpad RAM and is unaccessible and 8kb is used by
1130
; the kernel.
1131
;
1132
; First uses the pattern AAAAAAAA to memory
1133
;                        55555555
1134
;
1135
; Then uses the pattern  55555555 to memory
1136
;                        AAAAAAAA
1137
;------------------------------------------------------------------------------
1138
 
1139
DBGRamTest:
1140
                addui   sp,sp,#-8
1141
                sws             c1,[sp]
1142
                ldi             r10,#$AAAAAAAA
1143
                ldi             r11,#$55555555
1144
                bsr             DBGRamTest1
1145
                ldi             r10,#$55555555
1146
                ldi             r11,#$AAAAAAAA
1147
                bsr             DBGRamTest1
1148
                lws             c1,[sp]
1149
                addui   sp,sp,#8
1150
                rts
1151
 
1152
;------------------------------------------------------------------------------
1153
;------------------------------------------------------------------------------
1154
 
1155
DBGRamTest1:
1156
                addui   sp,sp,#-8
1157
                sws             c1,[sp]
1158
 
1159
                mov             r1,r10
1160
                mov             r3,r11
1161
                ldi             r5,#$6000
1162
                ldi             lc,#$3FF3FF             ; (32MB - 24kB)/8 - 1
1163
                mov             r8,r0
1164
.0001:
1165
                sh              r1,zs:[r5]
1166
                sh              r3,zs:4[r5]
1167
                addui   r5,r5,#8
1168
                andi    r4,r5,#$FFF
1169
                tst             p0,r4
1170
p0.eq   shrui   r4,r5,#12
1171
p0.eq   ldi             r2,#0
1172
p0.eq   ldi             r6,#1
1173
p0.eq   bsr             DBGDisplayCharr
1174
                loop    .0001
1175
 
1176
                ldi             r5,#$6000
1177
                ldi             lc,#$3FF3FF             ; (32MB - 24kB)/8 - 1
1178
.0002:
1179
                lh              r1,zs:[r5]
1180
                lh              r3,zs:4[r5]
1181
                cmp             p0,r1,r10
1182
p0.ne   mov             r7,r1
1183
p0.ne   bsr             DBGBadRam
1184
                cmp             p0,r3,r11
1185
p0.ne   mov             r7,r3
1186
p0.ne   bsr             DBGBadRam
1187
                addui   r5,r5,#8
1188
                andi    r4,r5,#$FFF
1189
                tst             p0,r4
1190
p0.eq   shrui   r4,r5,#12
1191
p0.eq   ldi             r2,#0
1192
p0.eq   ldi             r6,#1
1193
p0.eq   bsr             DBGDisplayCharr
1194
                loop    .0002
1195
                lws             c1,[sp]
1196
                addui   sp,sp,#8
1197
                rts
1198
 
1199
;------------------------------------------------------------------------------
1200
; Dispay bad ram nessage with address and data.
1201
;------------------------------------------------------------------------------
1202
 
1203
DBGBadRam:
1204
                addui   sp,sp,#-8
1205
                sws             c1,[sp]
1206
                lla             r1,cs:msgBadRam
1207
                ldi             r2,#0
1208
                ldi             r6,#2
1209
                addu    r6,r6,r8
1210
                bsr             DBGDispString
1211
                mov             r4,r5
1212
                bsr             DBGDisplayHalf
1213
                bsr             space1
1214
                mov             r4,r7
1215
                bsr             DBGDisplayHalf
1216
                addui   r8,r8,#1
1217
                andi    r8,r8,#15
1218
                cmpi    p0,r8,#15
1219
p0.eq   ldis    lc,#1
1220
                lws             c1,[sp]
1221
                addui   sp,sp,#8
1222
                rts
1223
 
1224
msgBadRam:
1225
        byte    "Menory failed at: ",0
1226
 
1227
;------------------------------------------------------------------------------
1228
; Reverse the video attribute.
1229
;------------------------------------------------------------------------------
1230
 
1231
ReverseVideo:
1232
                lhu             r1,NormAttr
1233
                shrui   r2,r1,#9
1234
                shli    r3,r1,#9
1235
                andi    r2,r2,#%111111111_0000000000
1236
                andi    r3,r3,#%111111111_000000000_0000000000
1237
                or              r1,r2,r3
1238
                rts
1239
 
1240
;------------------------------------------------------------------------------
1241
;------------------------------------------------------------------------------
1242
; Tables
1243
;------------------------------------------------------------------------------
1244
;------------------------------------------------------------------------------
1245
 
1246
        align   2
1247
DBGFuncT:
1248
                dc              gf0,gf1,gf2,gf3,gf4,gf5,gf6,gf7,gf8,gf9,gfA,gfB,gf0,gf0,gf0,gf0
1249
 
1250
                align   2
1251
DBGLineTbl:
1252
                dc              0
1253
                dc              1*84
1254
                dc              2*84
1255
                dc              3*84
1256
                dc              4*84
1257
                dc              5*84
1258
                dc              6*84
1259
                dc              7*84
1260
                dc              8*84
1261
                dc              9*84
1262
                dc              10*84
1263
                dc              11*84
1264
                dc              12*84
1265
                dc              13*84
1266
                dc              14*84
1267
                dc              15*84
1268
                dc              16*84
1269
                dc              17*84
1270
                dc              18*84
1271
                dc              19*84
1272
                dc              20*84
1273
                dc              21*84
1274
                dc              22*84
1275
                dc              23*84
1276
                dc              24*84
1277
                dc              25*84
1278
                dc              26*84
1279
                dc              27*84
1280
                dc              28*84
1281
                dc              29*84
1282
                dc              30*84
1283
                dc              31*84
1284
 
1285
; Table of the length of each instruction.
1286
;
1287
DBGInsnLength:
1288
                byte    3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3      ; TST
1289
                byte    4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4      ; CMP
1290
                byte    4,4,4,4, 4,4,4,4, 4,4,4,4, 4,4,4,4      ; CMPI
1291
                byte    3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3      ; BR
1292
 
1293
                byte    5,4,5,1, 1,1,5,4, 5,5,5,5, 5,5,5,5
1294
                byte    5,5,1,5, 5,5,1,1, 5,1,1,1, 1,1,1,1
1295
                byte    1,1,1,1, 1,1,1,1, 1,1,1,5, 5,5,5,4
1296
                byte    1,1,5,1, 1,1,1,4, 5,4,1,1, 1,1,1,1
1297
 
1298
                byte    5,5,5,5, 5,5,5,1, 1,1,1,5, 5,1,5,5
1299
                byte    5,5,5,5, 1,1,5,6, 5,5,5,5, 1,4,5,4
1300
                byte    3,5,6,3, 3,4,4,4, 4,4,6,4, 5,5,5,5
1301
                byte    5,5,5,5, 5,5,5,1, 1,1,1,1, 1,1,1,1
1302
 
1303
                byte    5,5,5,5, 1,1,5,6, 3,5,3,5, 3,1,1,1
1304
                byte    1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1
1305
                byte    1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1
1306
                byte    4,2,4,2, 2,5,4,2, 2,2,2,2, 2,1,1,2
1307
 
1308
; Table of operand format indexes
1309
;
1310
; 0 = px,rx
1311
; 1 = px,rx,rx
1312
; 2 = px,rx,#imm
1313
; 3 = disp12
1314
; 4 = rx,rx,rx
1315
; 5 = rx,rx
1316
; 6 = px,px,px
1317
; 7 = none
1318
; 8 = px,rx,#imm (biti)
1319
; 9 = rx,#imm   (addui short)
1320
; 10 = rx,rx,#imm
1321
; 11 = mlo
1322
; 12 = shift
1323
; 13 = rx,#imm  (ldi)
1324
; 14 = rx,rx,rx,rx      (mux format)
1325
; 15 = rx,mem           (load/store)
1326
; 16 = rx,rx,rx,[rx]    (cas)
1327
; 17 = rx,[rx]          (stset)
1328
; 18 = [rx],[rx],rx     (stmov/stcmp)
1329
; 19 = rx,#imm  (cache)
1330
; 20 = [cx]             jsr
1331
; 21 = jsr
1332
; 22 = jsr
1333
; 23 = rts
1334
; 24 = loop
1335
; 25 = sys/int
1336
; 26 = rx,spr
1337
; 27 = spr,rx
1338
; 28 = bitfield
1339
; 29 = spr,spr
1340
; 30 = rx,[rx+rx*sc]    (load/store)
1341
; 31 = stix
1342
; 32 = inc
1343
; 33 = tlb
1344
; 34 = rts
1345
; 35 = bcd
1346
; 36 = stp
1347
; 37 = imm
1348
 
1349
DBGOperFmt:
1350
                byte    0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0      ; TST   px,rx
1351
                byte    1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1      ; CMP   px,rx,rx
1352
                byte    2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2      ; CMPI  px,rx,#imm
1353
                byte    3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3      ; BR
1354
 
1355
                byte    4,5,6,7, 7,7,8,9, 10,10,10,10, 10,10,10,10
1356
                byte    4,11,7,10, 10,10,7,7, 12,7,7,7, 7,7,7,7
1357
                byte    7,7,7,7, 7,7,7,7, 7,7,7,10, 10,10,10,13
1358
                byte    7,7,14,7, 7,7,7,5, 4,6,7,7, 7,7,7,7
1359
 
1360
                byte    15,15,15,15, 15,15,15,7, 7,7,7,15, 15,7,15,15
1361
                byte    15,15,15,15, 7,7,15,16, 17,18,18,17, 7,38,15,19
1362
                byte    20,21,22,23, 24,25,25,5, 26,27,28,29, 15,15,15,15
1363
                byte    30,30,30,30, 30,30,30,7, 7,7,7,7, 7,7,7,7
1364
 
1365
                byte    30,30,30,30, 7,7,31,32, 7,7,7,7, 7,7,7,7
1366
                byte    7,7,7,7, 7,7,7,7, 7,7,7,7, 7,7,7,7
1367
                byte    7,7,7,7, 7,7,7,7, 7,7,7,7, 7,7,7,7
1368
                byte    33,7,34,7, 7,35,36,7, 7,7,7,7, 7,7,7,37
1369
 
1370
                align   2
1371
 
1372
DBGOperFmtT:
1373
                dc              DBGDispTstregs,DBGDispCmpregs,DBGDispBrDisp,DBGDispCmpimm,DBGDispRxRxRx,DBGDispRxRx,DBGDispPxPxPx,DBGDispNone
1374
                dc              DBGDispPxRxImm,DBGDispRxImm,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispRxImm,DBGDispNone,DBGDispNone
1375
                dc              DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone
1376
                dc              DBGDispNone,DBGDispNone,DBGDispNone,DBGDispSprRx,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone
1377
                dc              DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone,DBGDispNone
1378
 
1379
                ; Table of instruction mnemonic string addresses
1380
                ; If the most signficant 12 bits are $FFF then a second table is referred to.
1381
                ;
1382
                align   2
1383
DBGInsnMne:
1384
                dc              mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst,mne_tst
1385
                dc              mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp,mne_cmp
1386
                dc              mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi,mne_cmpi
1387
                dc              mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br,mne_br
1388
                dc              $FFF0,$FFF1,$FFF2,mne_q,mne_q,mne_q,mne_biti,mne_addui,mne_addi,mne_subi,mne_muli,mne_divi,mne_addui,mne_subui,mne_mului,mne_divui
1389
                dc              $FFF3,mne_mlo,mne_q,mne_andi,mne_ori,mne_eori,mne_q,mne_q,$FFF4,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1390
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_2addui,mne_4addui,mne_8addui,mne_16addui,mne_ldi
1391
                dc              mne_q,mne_q,mne_mux,mne_q,mne_q,mne_q,mne_q,$FFF5,$FFF6,$FFF7,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1392
                dc              mne_lb,mne_lbu,mne_lc,mne_lcu,mne_lh,mne_lhu,mne_lw,mne_q,mne_q,mne_q,mne_q,mne_lvwar,mne_swcr,mne_q,mne_lws,mne_lcl
1393
                dc              mne_sb,mne_sc,mne_sh,mne_sw,mne_q,mne_q,mne_sti,mne_cas,mne_stset,mne_stmov,mne_stcmp,mne_stfnd,mne_q,mne_ldis,mne_sws,mne_cache
1394
                dc              mne_jsr,mne_jsr,mne_jsr,mne_rts,mne_loop,mne_sys,mne_int,$FFF8,mne_mfspr,mne_mtspr,$FFF9,mne_movs,mne_lvb,mne_lvc,mne_lvh,mne_lvw
1395
                dc              mne_lb,mne_lbu,mne_lc,mne_lcu,mne_lh,mne_lhu,mne_lw,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1396
                dc              mne_sbx,mne_scx,mne_sh,mne_sw,mne_q,mne_q,mne_sti,mne_inc,mne_push,mne_pea,mne_pop,mne_link,mne_unlink,mne_q,mne_q,mne_q
1397
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1398
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1399
                dc              $FFFA,mne_nop,mne_rts,mne_rte,mne_rti,$FFFB,mne_stp,mne_sync,mne_memsb,mne_memdb,mne_cli,mne_sei,mne_rtd,mne_q,mne_q,mne_imm
1400
DBGInsnMne0:
1401
                dc              mne_add,mne_sub,mne_mul,mne_div,mne_addu,mne_subu,mne_mulu,mne_divu,mne_2addu,mne_4addu,mne_8addu,mne_16addu,mne_q,mne_q,mne_q,mne_q
1402
                dc              mne_min,mne_max,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1403
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1404
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1405
DBGInsnMne1:
1406
                dc              mne_cpuid,mne_redor,mne_redand,mne_par,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1407
DBGInsnMne2:
1408
                dc              mne_pand,mne_por,mne_peor,mne_pnand,mne_pnor,mne_penor,mne_pandc,mne_porc,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1409
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1410
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1411
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1412
DBGInsnMne3:
1413
                dc              mne_and,mne_or,mne_eor,mne_nand,mne_nor,mne_enor,mne_andc,mne_orc,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1414
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1415
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1416
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1417
DBGInsnMne4:
1418
                dc              mne_shl,mne_shr,mne_shlu,mne_shru,mne_rol,mne_ror,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1419
                dc              mne_shli,mne_shri,mne_shlui,mne_shrui,mne_roli,mne_rori,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1420
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1421
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1422
DBGInsnMne5:
1423
                dc              mne_fmov,mne_q,mne_ftoi,mne_itof,mne_fneg,mne_fabs,mne_fsign,mne_fman,mne_fnabs,mne_q,mne_q,mne_q,mne_fstat,mne_frm,mne_q,mne_q
1424
DBGInsnMne6:
1425
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_fcmp,mne_fadd,mne_fsub,mne_fmul,mne_fdiv,mne_q,mne_q,mne_q,mne_q
1426
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_fcmp,mne_fadd,mne_fsub,mne_fmul,mne_fdiv,mne_q,mne_q,mne_q,mne_q
1427
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1428
                dc              mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1429
DBGInsnMne7:
1430
DBGInsnMne8:
1431
                dc              mne_mov,mne_neg,mne_not,mne_abs,mne_sign,mne_cntlz,mne_cntlo,mne_cntpop,mne_sxb,mne_sxc,mne_sxh,mne_com,mne_zxb,mne_zxc,mne_zxh,mne_q
1432
DBGInsnMne9:
1433
                dc              mne_bfins,mne_bfset,mne_bfclr,mne_bfchg,mne_bfextu,mne_bfext,mne_bfinsi,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1434
DBGInsnMneA:
1435
                dc              mne_q,mne_q,mne_tlbrdreg,mne_tlbwrreg,mne_tlbwi,mne_tlben,mne_tlbdis,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1436
DBGInsnMneB:
1437
                dc              mne_bcdadd,mne_bcdsub,mne_bcdmul,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q,mne_q
1438
DBGInsnMneT:
1439
                dc              DBGInsnMne0,DBGInsnMne1,DBGInsnMne2,DBGInsnMne3,DBGInsnMne4,DBGInsnMne5,DBGInsnMne6,DBGInsnMne7,DBGInsnMne8,DBGInsnMne9,DBGInsnMneA,DBGInsnMneB
1440
 
1441
; Table of predicate conditions
1442
;
1443
DBGPredCons:
1444
                byte    "f  ","f  ","eq ","ne ","le ","gt ","lt ","ge ","leu","gtu","ltu","geu","   ","   ","   ","   "
1445
 
1446
; Special purpose register names
1447
;
1448
DBGSpr:
1449
                byte    "p0 ","p1 ","p2 ","p3 ","p4 ","p5 ","p6 ","p7 ","p8 ","p9 ","p10","p11","p12","p13","p14","p15"
1450
                byte    "c0 ","c1 ","c2 ","c3 ","c4 ","c5 ","c6 ","c7 ","c8 ","c9 ","c10","c11","c12","c13","c14","c15"
1451
                byte    "zs ","ds ","es ","fs ","gs ","hs ","ss ","cs ","zsl","dsl","esl","fsl","gsl","hsl","ssl","csl"
1452
                byte    "pra","   ","tck","lc ","   ","   ","asd","sr ","   ","   ","   ","   ","   ","   ","   ","   "
1453
 
1454
; Table of mnemonics
1455
;
1456
mne_16addu:     byte    "16add",'u'|$80
1457
mne_2addu:      byte    "2add",'u'|$80
1458
mne_4addu:      byte    "4add",'u'|$80
1459
mne_8addu:      byte    "8add",'u'|$80
1460
mne_16addui:    byte    "16addu",'i'|$80
1461
mne_2addui:     byte    "2addu",'i'|$80
1462
mne_4addui:     byte    "4addu",'i'|$80
1463
mne_8addui:     byte    "8addu",'i'|$80
1464
mne_add:        byte    "ad",'d'|$80
1465
mne_addi:       byte    "add",'i'|$80
1466
mne_addu:       byte    "add",'u'|$80
1467
mne_addui:      byte    "addu",'i'|$80
1468
mne_and:        byte    "an",'d'|$80
1469
mne_andi:       byte    "and",'i'$80
1470
mne_bfchg:      byte    "bfch",'g'|$80
1471
mne_bfclr:      byte    "bfcl",'r'|$80
1472
mne_bfext:      byte    "bfex",'t'|$80
1473
mne_bfextu:     byte    "bfext",'u'|$80
1474
mne_bfins:      byte    "bfin",'s'|$80
1475
mne_bfinsi:     byte    "bfins",'i'|$80
1476
mne_bfset:      byte    "bfse",'t'|$80
1477
mne_biti:       byte    "bit",'i'|$80
1478
mne_br:         byte    "b",'r'|$80
1479
mne_brk:        byte    "br",'k'|$80
1480
mne_bsr:        byte    "bs",'r'|$80
1481
mne_cmp:        byte    "cm",'p'|$80
1482
mne_cmpi:       byte    "cmp",'i'|$80
1483
mne_div:        byte    "di",'v'|$80
1484
mne_divi:       byte    "div",'i'|$80
1485
mne_divu:       byte    "div",'u'|$80
1486
mne_divui:      byte    "divu",'i'|$80
1487
mne_eor:        byte    "eo",'r'|$80
1488
mne_eori:       byte    "eor",'i'|$80
1489
mne_imm:        byte    "im",'m'|$80
1490
mne_jsr         byte    "js",'r'|$80
1491
mne_lb:         byte    "l",'b'|$80
1492
mne_lbu:        byte    "lb",'u'|$80
1493
mne_lc:         byte    "l",'c'|$80
1494
mne_lcu:        byte    "lc",'u'|$80
1495
mne_ldi:        byte    "ld",'i'|$80
1496
mne_ldis:       byte    "ldi",'s'|$80
1497
mne_lh:         byte    "l",'h'|$80
1498
mne_lhu:        byte    "lh",'u'|$80
1499
mne_loop:       byte    "loo",'p'|$80
1500
mne_lvb:        byte    "lv",'b'|$80
1501
mne_lvc:        byte    "lv",'c'|$80
1502
mne_lvh:        byte    "lv",'h'|$80
1503
mne_lvw:        byte    "lv",'w'|$80
1504
mne_lw:         byte    "l",'w'|$80
1505
mne_lws:        byte    "lw",'s'|$80
1506
mne_mfspr:      byte    "mfsp",'r'|$80
1507
mne_mtspr:      byte    "mtsp",'r'|$80
1508
mne_mov:        byte    "mo",'v'|$80
1509
mne_movs:       byte    "mov",'s'|$80
1510
mne_mul:        byte    "mu",'l'|$80
1511
mne_muli:       byte    "mul",'i'|$80
1512
mne_mulu:       byte    "mul",'u'|$80
1513
mne_mului:      byte    "mulu",'i'|$80
1514
mne_nop:        byte    "no",'p'|$80
1515
mne_or:         byte    "o",'r'|$80
1516
mne_ori:        byte    "or",'i'|$80
1517
mne_q:          byte    "??",'?'|$80
1518
mne_rol:        byte    "ro",'l'|$80
1519
mne_roli:       byte    "rol",'i'|$80
1520
mne_ror:        byte    "ro",'r'|$80
1521
mne_rori:       byte    "ror",'i'|$80
1522
mne_rtd:        byte    "rt",'d'|$80
1523
mne_rte:        byte    "rt",'e'|$80
1524
mne_rti:        byte    "rt",'i'|$80
1525
mne_rts:        byte    "rt",'s'|$80
1526
mne_sb:         byte    "s",'b'|$80
1527
mne_sc:         byte    "s",'c'|$80
1528
mne_sh:         byte    "s",'h'|$80
1529
mne_shl:        byte    "sh",'l'|$80
1530
mne_shli:       byte    "shl",'i'|$80
1531
mne_shr:        byte    "sh",'r'|$80
1532
mne_shri:       byte    "shr",'i'|$80
1533
mne_shru:       byte    "shr",'u'|$80
1534
mne_shrui:      byte    "shru",'i'|$80
1535
mne_stp:        byte    "st",'p'|$80
1536
mne_sub:        byte    "su",'b'|$80
1537
mne_subu:       byte    "sub",'u'|$80
1538
mne_sw:         byte    "s",'w'|$80
1539
mne_sync:       byte    "syn",'c'|$80
1540
mne_sys:        byte    "sy",'s'|$80
1541
mne_tlben:      byte    "tlbe",'n'|$80
1542
mne_tlbdis:     byte    "tlbdi",'s'|$80
1543
mne_tlbrdreg:   byte    "tlbrdre",'g'|$80
1544
mne_tlbwi:      byte    "tlbw",'i'|$80
1545
mne_tlbwrreg:   byte    "tlbwrre",'g'|$80
1546
mne_tst:        byte    "ts",'t'|$80
1547
 
1548
msgDebugger:
1549
        byte    "Thor Debugger (C) 2015 Robert Finch",0
1550
 

powered by: WebSVN 2.1.0

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