diff --git a/debug/asm.asm b/debug/asm.asm new file mode 100644 index 0000000..b822346 --- /dev/null +++ b/debug/asm.asm @@ -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 + diff --git a/debug/chario.asm b/debug/chario.asm index 08ef004..e63fb48 100644 --- a/debug/chario.asm +++ b/debug/chario.asm @@ -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 diff --git a/debug/edit.asm b/debug/edit.asm index b3c6920..60d2114 100644 --- a/debug/edit.asm +++ b/debug/edit.asm @@ -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 diff --git a/debug/names.asm b/debug/names.asm index 8633faa..f9e0a88 100644 --- a/debug/names.asm +++ b/debug/names.asm @@ -8,3 +8,6 @@ fnames: ; control flags db "++++ODIT" ; status flags db "SZ+A+P+C" + +instr: +.db: db "DB", 0 diff --git a/debug/run.asm b/debug/run.asm index d110254..98bb634 100644 --- a/debug/run.asm +++ b/debug/run.asm @@ -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, '-' diff --git a/debug/util.asm b/debug/util.asm index bc68815..420eedf 100644 --- a/debug/util.asm +++ b/debug/util.asm @@ -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 diff --git a/rom/debug.asm b/rom/debug.asm index f406b90..f585b22 100644 --- a/rom/debug.asm +++ b/rom/debug.asm @@ -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