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

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [source/] [Debugger.asm] - Blame information for rev 34

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

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

powered by: WebSVN 2.1.0

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