debug: Implement number parsing and editing of registers
This commit is contained in:
parent
a386416f28
commit
8407275ba9
4 changed files with 246 additions and 104 deletions
110
rom/debug.asm
110
rom/debug.asm
|
@ -58,99 +58,8 @@ init: push ds
|
|||
retf
|
||||
|
||||
%include "debug/parse.asm"
|
||||
|
||||
; Print AL
|
||||
space: mov al, ' '
|
||||
putc: xor bx, bx
|
||||
mov ah, 0x0e
|
||||
int 0x10
|
||||
ret
|
||||
|
||||
; Print code string CS:SI
|
||||
putcs: push ds
|
||||
push cs
|
||||
pop ds
|
||||
call putds
|
||||
pop ds
|
||||
ret
|
||||
|
||||
; Print data string DS:SI
|
||||
putds: lodsb
|
||||
test al, al
|
||||
jz .ret
|
||||
call putc
|
||||
jmp putds
|
||||
.ret: ret
|
||||
|
||||
crlf: mov al, 0x0A
|
||||
call putc
|
||||
mov al, 0x0D
|
||||
jmp putc
|
||||
|
||||
print16:
|
||||
; setup bx and ah for int 10h call
|
||||
xor bx, bx
|
||||
mov ah, 0x0e
|
||||
mov cl, 4
|
||||
; this double-call is essentially a 4 times repeating loop
|
||||
call .c1
|
||||
.c1: call .c2
|
||||
.c2: ; grab highest nibble from dx
|
||||
mov al, dh
|
||||
; remove highest nibble from dx
|
||||
shl dx, cl
|
||||
; shift away second-highest nibble that we accidentally copied
|
||||
shr al, cl
|
||||
; map 0-9 to ascii codes for '0' to '9'
|
||||
add al, 0x30
|
||||
; if result is larger than '9', ...
|
||||
cmp al, 0x3a
|
||||
jl .noadj
|
||||
; ... add 7 so we continue at 'A'
|
||||
add al, 7
|
||||
.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
|
||||
%include "debug/chario.asm"
|
||||
%include "debug/edit.asm"
|
||||
|
||||
int3entry:
|
||||
; save DS and load bss segment from IVT
|
||||
|
@ -191,7 +100,10 @@ loop: ; show prompt
|
|||
mov al, '-'
|
||||
call putc
|
||||
; read data
|
||||
call read
|
||||
mov byte [inmin], 1
|
||||
mov byte [inmax], 16
|
||||
mov word [ingetc], getc
|
||||
call gets
|
||||
pushf
|
||||
call crlf
|
||||
popf
|
||||
|
@ -228,7 +140,7 @@ return: ; restore stack pointer
|
|||
%include "debug/names.asm"
|
||||
|
||||
; Expects DI to mark end of command
|
||||
runcmd: mov si, cmdbuf
|
||||
runcmd: mov si, inbuf
|
||||
lodsb
|
||||
cmp al, 'g'
|
||||
je cmd_g
|
||||
|
@ -256,6 +168,8 @@ cmd_r: cmp byte [si], 0
|
|||
je printregs
|
||||
call eat_register
|
||||
jc .err
|
||||
call edit_word
|
||||
call crlf
|
||||
ret
|
||||
.err: mov di, eat_register.emsg
|
||||
jmp parse_error
|
||||
|
@ -324,8 +238,10 @@ reg_ds: resw 1
|
|||
reg_ip: resw 1
|
||||
reg_fl: resw 1
|
||||
|
||||
cmdlen: equ 16
|
||||
cmdbuf: resb cmdlen
|
||||
ingetc: resw 1
|
||||
inmin: resb 1
|
||||
inmax: resb 1
|
||||
inbuf: resb 0x20
|
||||
|
||||
; reserve at least 80h words for stack
|
||||
resw 0x80
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue