debug: Implement parsing of register names

This commit is contained in:
Nero 2020-05-18 20:05:06 +02:00
parent 2a7087a21f
commit fc1aa47039
4 changed files with 140 additions and 61 deletions

10
debug/names.asm Normal file
View file

@ -0,0 +1,10 @@
rnames: ; 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"

58
debug/parse.asm Normal file
View file

@ -0,0 +1,58 @@
; IN DS:SI remaining unparsed string
; CS:DI error message
parse_error:
push si
mov si, di
call putcs
mov al, ':'
call putc
mov al, ' '
call putc
pop si
call putds
jmp crlf
eat_whitespace:
; peek on next char
mov al, [si]
; ES := CS
push es
push cs
pop es
; string search
mov di, .chars
mov cx, 4
scasb
; restore bss segment
pop es
jne .ret
inc si
jmp eat_whitespace
.chars: db 0x09, 0x0A, 0x0D, 0x20
.ret: ret
; IN: DS:SI string to read
; OUT: CF set if no match
; BX register number * 2 if CF clear
eat_register:
push si
push es
lodsw
and ax, 0xDFDF
; ES := CS
push cs
pop es
mov di, rnames
mov cx, 14
repne scasw
pop es
jne .fail
pop bx
mov bx, di
sub bx, (rnames+2)
clc
ret
.fail: pop si
stc
ret
.emsg: db "Not a register name", 0