Add hexdump for kernel
This commit is contained in:
parent
f6b8df0598
commit
e07e13fd35
85
kernel/dump.asm
Normal file
85
kernel/dump.asm
Normal file
@ -0,0 +1,85 @@
|
||||
; print a word
|
||||
; in: ax
|
||||
print16:
|
||||
xchg ah,al
|
||||
call print8
|
||||
xchg ah,al
|
||||
|
||||
; print a byte
|
||||
; in: al
|
||||
print8:
|
||||
push ax ; avoid destroying ah
|
||||
push bx
|
||||
xor bx, bx
|
||||
aam 16 ; high nibble moved into ah, low nibble into al
|
||||
add ax, 0x3030
|
||||
push ax
|
||||
xchg al, ah
|
||||
call .nib
|
||||
pop ax
|
||||
call .nib
|
||||
pop bx
|
||||
pop ax
|
||||
ret
|
||||
.nib:
|
||||
cmp al, 0x3a
|
||||
jl .out
|
||||
add al, 0x07
|
||||
.out:
|
||||
mov dl, al
|
||||
call console_output
|
||||
ret
|
||||
|
||||
dump:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push bx
|
||||
mov dl, 0x0A
|
||||
call console_output
|
||||
mov dl, 0x0D
|
||||
call console_output
|
||||
mov cx, 4
|
||||
.loop_line:
|
||||
push cx
|
||||
push bx
|
||||
mov ax, bx
|
||||
call print16
|
||||
mov dl, ':'
|
||||
call console_output
|
||||
mov dl, ' '
|
||||
call console_output
|
||||
mov cx, 0x8
|
||||
.loop_bin:
|
||||
mov ax, [bx]
|
||||
xchg al, ah
|
||||
inc bx
|
||||
inc bx
|
||||
call print16
|
||||
mov dl, ' '
|
||||
call console_output
|
||||
loop .loop_bin
|
||||
pop bx
|
||||
mov cx, 0x10
|
||||
.loop_ascii:
|
||||
mov dl, '.'
|
||||
cmp byte [bx], 0x20
|
||||
jc .print
|
||||
cmp byte [bx], 0x80
|
||||
jnc .print
|
||||
mov dl, [bx]
|
||||
.print:
|
||||
inc bx
|
||||
call console_output
|
||||
loop .loop_ascii
|
||||
pop cx
|
||||
mov dl, 0x0A
|
||||
call console_output
|
||||
mov dl, 0x0D
|
||||
call console_output
|
||||
loop .loop_line
|
||||
pop bx
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
Loading…
Reference in New Issue
Block a user