debug: Implement parsing of register names
This commit is contained in:
parent
2a7087a21f
commit
fc1aa47039
4 changed files with 140 additions and 61 deletions
131
rom/debug.asm
131
rom/debug.asm
|
@ -6,8 +6,7 @@ bssvec: equ 0xB6
|
|||
|
||||
db 0x55, 0xAA
|
||||
db 0x00
|
||||
jmp init
|
||||
nop
|
||||
jmp near init
|
||||
|
||||
times (0x18 - ($-$$)) db 0
|
||||
dw 0
|
||||
|
@ -58,6 +57,8 @@ init: push ds
|
|||
pop ds
|
||||
retf
|
||||
|
||||
%include "debug/parse.asm"
|
||||
|
||||
; Print AL
|
||||
space: mov al, ' '
|
||||
putc: xor bx, bx
|
||||
|
@ -65,17 +66,21 @@ putc: xor bx, bx
|
|||
int 0x10
|
||||
ret
|
||||
|
||||
; Print CS:SI
|
||||
puts: push ds
|
||||
; Print code string CS:SI
|
||||
putcs: push ds
|
||||
push cs
|
||||
pop ds
|
||||
.loop: lodsb
|
||||
call putds
|
||||
pop ds
|
||||
ret
|
||||
|
||||
; Print data string DS:SI
|
||||
putds: lodsb
|
||||
test al, al
|
||||
jz .ret
|
||||
call putc
|
||||
jmp .loop
|
||||
.ret: pop ds
|
||||
ret
|
||||
jmp putds
|
||||
.ret: ret
|
||||
|
||||
crlf: mov al, 0x0A
|
||||
call putc
|
||||
|
@ -106,6 +111,47 @@ print16:
|
|||
.noadj: int 0x10
|
||||
ret
|
||||
|
||||
getc: xor ax, ax
|
||||
int 0x16
|
||||
test al, al
|
||||
jz getc
|
||||
ret
|
||||
|
||||
read: mov di, cmdbuf
|
||||
.loop: call getc
|
||||
cmp al, 0x03
|
||||
je .can
|
||||
cmp al, 0x0D
|
||||
je .enter
|
||||
cmp al, 0x08
|
||||
je .bs
|
||||
cmp di, cmdbuf+cmdlen-1
|
||||
jnc .loop
|
||||
stosb
|
||||
mov ah, 0x0e
|
||||
xor bx, bx
|
||||
int 0x10
|
||||
jmp .loop
|
||||
ret
|
||||
.bs: cmp di, cmdbuf
|
||||
jbe .loop
|
||||
xor bx, bx
|
||||
mov ax, 0x0e08
|
||||
int 0x10
|
||||
mov al, 0x20
|
||||
int 0x10
|
||||
mov al, 0x08
|
||||
int 0x10
|
||||
dec di
|
||||
jmp .loop
|
||||
.can: xor al, al
|
||||
stosb
|
||||
stc
|
||||
ret
|
||||
.enter: xor al, al
|
||||
stosb
|
||||
ret
|
||||
|
||||
int3entry:
|
||||
; save DS and load bss segment from IVT
|
||||
push ds
|
||||
|
@ -143,7 +189,7 @@ int3entry:
|
|||
|
||||
loop: ; show prompt
|
||||
mov al, '-'
|
||||
int 0x10
|
||||
call putc
|
||||
; read data
|
||||
call read
|
||||
pushf
|
||||
|
@ -179,54 +225,11 @@ return: ; restore stack pointer
|
|||
; final jump back
|
||||
iret
|
||||
|
||||
names: ; general purpose regs
|
||||
db "AXCXDXBXSPBPSIDI"
|
||||
; segment regs
|
||||
db "ESCSSSDS"
|
||||
; special regs
|
||||
db "IPFL"
|
||||
fnames: ; control flags
|
||||
db "++++ODIT"
|
||||
; status flags
|
||||
db "SZ+A+P+C"
|
||||
%include "debug/names.asm"
|
||||
|
||||
getc: xor ax, ax
|
||||
int 0x16
|
||||
test al, al
|
||||
jz getc
|
||||
ret
|
||||
|
||||
read: mov di, cmdbuf
|
||||
.loop: call getc
|
||||
cmp al, 0x03
|
||||
je .can
|
||||
cmp al, 0x0D
|
||||
je .enter
|
||||
cmp al, 0x08
|
||||
je .bs
|
||||
cmp di, cmdbuf+cmdlen
|
||||
jnc .loop
|
||||
stosb
|
||||
mov ah, 0x0e
|
||||
xor bx, bx
|
||||
int 0x10
|
||||
jmp .loop
|
||||
ret
|
||||
.bs: cmp di, cmdbuf
|
||||
jbe .loop
|
||||
xor bx, bx
|
||||
mov ax, 0x0e08
|
||||
int 0x10
|
||||
mov al, 0x20
|
||||
int 0x10
|
||||
mov al, 0x08
|
||||
int 0x10
|
||||
dec di
|
||||
jmp .loop
|
||||
.can: stc
|
||||
.enter: ret
|
||||
|
||||
runcmd: mov al, [cmdbuf]
|
||||
; Expects DI to mark end of command
|
||||
runcmd: mov si, cmdbuf
|
||||
lodsb
|
||||
cmp al, 'g'
|
||||
je cmd_g
|
||||
cmp al, 'r'
|
||||
|
@ -235,12 +238,12 @@ runcmd: mov al, [cmdbuf]
|
|||
je cmd_t
|
||||
cmp al, '?'
|
||||
je cmd_?
|
||||
mov al, '?'
|
||||
cerr: mov al, '?'
|
||||
call putc
|
||||
jmp crlf
|
||||
|
||||
cmd_?: mov si, .txt
|
||||
jmp puts
|
||||
jmp putcs
|
||||
.txt: db "g Go", 0x0A, 0x0D
|
||||
db "r Print register values", 0x0A, 0x0D
|
||||
db "t Single-Step", 0x0A, 0x0D
|
||||
|
@ -249,7 +252,15 @@ cmd_?: mov si, .txt
|
|||
cmd_g: and word [reg_fl+1], 0xfe
|
||||
jmp return
|
||||
|
||||
cmd_r: jmp printregs
|
||||
cmd_r: cmp di, si
|
||||
je printregs
|
||||
call eat_register
|
||||
jc .err
|
||||
mov dx, si
|
||||
call print16
|
||||
ret
|
||||
.err: mov di, eat_register.emsg
|
||||
jmp parse_error
|
||||
|
||||
cmd_t: or word [reg_fl+1], 0x03
|
||||
jmp return
|
||||
|
@ -260,7 +271,7 @@ printregs:
|
|||
mov ah, 0x0e
|
||||
mov si, reg_ax
|
||||
.loop: push cx
|
||||
mov dx, [cs:si+names]
|
||||
mov dx, [cs:si+rnames]
|
||||
lodsw
|
||||
call printreg
|
||||
pop cx
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue