New bootsect program to dump bios data area, aid for debugging hw

This commit is contained in:
Nero 2020-12-15 20:16:42 +00:00
parent 6bdb1da2ed
commit c0bd238d54

71
boot/dumpbda.asm Normal file
View File

@ -0,0 +1,71 @@
org 0x7C00
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7C00
mov si, 0x400
loop: mov dx, si
call dmpdx
mov al, 0x20
int 0x10
int 0x10
push si
mov cx, 8
wloop: lodsw
xchg al, ah
mov dx, ax
push cx
call dmpdx
mov al, 0x20
int 0x10
pop cx
loop wloop
pop si
mov al, 0x20
int 0x10
mov cx, 16
aloop: lodsb
cmp al, 0x20
jnc noadj
mov al, '.'
noadj: int 0x10
loop aloop
mov al, 0x0A
int 0x10
mov al, 0x0D
int 0x10
cmp si, 0x500
jc loop
hlt: hlt
jmp hlt
dmpdx: ; setup bx and ah for int 10h call
xor bx, bx
mov ah, 0x0e
mov cl, 4
; this double-call is essentially a 4 times repeating loop
call dmpdx1
dmpdx1: call dmpdx2
dmpdx2: ; grab highest nibble from dx
mov al, dh
; remove highest nibble from dx
shl dx, cl
; shift away second-highest nibble that we accidentally copied
shr al, cl
; map 0-9 to ascii codes for '0' to '9'
add al, 0x30
; if result is larger than '9', ...
cmp al, 0x3a
jl dmpdx3
; ... add 7 so we continue at 'A'
add al, 7
dmpdx3: int 0x10
ret