rdos/debug/parse.asm

59 lines
786 B
NASM

; 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