Revamp debugger, including support for printing padded numbers

This commit is contained in:
Nero 2019-05-05 11:18:36 +00:00
parent dab565ee41
commit 8aafa98c6a
2 changed files with 132 additions and 34 deletions

View file

@ -48,24 +48,46 @@ printf:
call print_string
jmp .loop
; converts a integer to ascii
; in ax input integer
; bx base
; cx minimum number of digits
; out bx garbled
; dx garbled
print_number_padded:
xor dx, dx
div bx
push dx
dec cx
jz .nopad
call print_number_padded
jmp print_number.end
.nopad:
call print_number
jmp print_number.end
; converts a integer to ascii
; in ax input integer
; bx base
; out bx garbled
; dx garbled
print_number:
xor dx, dx
div bx ; ax = dx:ax / 10, dx = dx:ax % 10
and ax, ax
jz .print
push dx
and ax, ax
jz .end
call print_number
pop dx
.print:
mov al, dl
add al, 0x30
cmp al, 0x3A
jl .noadj
add al, 0x07
.noadj:
.end:
pop bx
xor bh, bh
add bx, print_chars
mov al, [cs:bx]
call putc
ret
; putc's a string
; in DS:AX null-terminated string
print_string:
push si
mov si, ax
@ -77,4 +99,7 @@ print_string:
jmp .loop
.end:
pop si
ret
ret
print_chars:
db "0123456789ABCDEF"