debug: Add stub for instruction decoding

This commit is contained in:
Nero 2020-05-19 18:26:22 +02:00
parent a31e574b3a
commit e60e49735c
7 changed files with 49 additions and 5 deletions

9
debug/asm.asm Normal file
View File

@ -0,0 +1,9 @@
; Prints instruction at ES:BX in human-readable form
disasm: call print_esbx
call space
mov si, instr.db
call putcs
call crlf
ret

View File

@ -28,7 +28,20 @@ crlf: mov al, 0x0A
mov al, 0x0D
jmp putc
print16:
print_dl:
mov cl, 4
; repeat 2 times
call .c
.c: mov al, dl
shl dx, cl
shr al, cl
add al, 0x30
cmp al, 0x3a
jl putc
add al, 7
jmp putc
print_dx:
mov cl, 4
; this double-call is essentially a 4 times repeating loop
call .c1
@ -48,6 +61,19 @@ print16:
add al, 7
jmp putc
print_esbx:
push cx
push dx
mov dx, es
call print_dx
mov al, ':'
call putc
mov dx, bx
call print_dx
pop dx
pop cx
ret
; Read character
getc: xor ax, ax
int 0x16

View File

@ -52,7 +52,7 @@ printreg:
mov al, '='
call putc
pop dx
call print16
call print_dx
call space
ret
@ -60,7 +60,7 @@ printreg:
edit_word:
push bx
mov dx, [es:bx]
call print16
call print_dx
mov al, '.'
call putc
mov byte [inmin], 4

View File

@ -8,3 +8,6 @@ fnames: ; control flags
db "++++ODIT"
; status flags
db "SZ+A+P+C"
instr:
.db: db "DB", 0

View File

@ -40,6 +40,11 @@ int3entry:
mov sp, stack
call crlf
call printregs
push es
mov es, [reg_cs]
mov bx, [reg_ip]
call disasm
pop es
loop: ; show prompt
mov al, '-'

View File

@ -14,12 +14,12 @@ cmd_h: call eat_whitespace
push dx
add dx, bx
call print16
call print_dx
call space
pop dx
sub dx, bx
call print16
call print_dx
jmp crlf
.err: mov di, eat_hex_word.emsg

View File

@ -81,6 +81,7 @@ cerr: mov al, '?'
%include "debug/edit.asm"
%include "debug/run.asm"
%include "debug/util.asm"
%include "debug/asm.asm"
align 512