I've been following a guide for creating an OS, just as an exercise, and it's been going fine until I reached the section where I attempt to read more data than just the boot sector from the disk. When I boot up the OS I see no output, just the blinking infinite loop cursor (AND NO ERROR MESSAGES), when it should display "Booting" followed by two Hex numbers. I'm using QEmu, and running this command:
qemu-system-x86_64 -drive format=raw,file=D:\booter.bin
Here is my code:
mov ah , 0x0e
[ org 0x7c00 ]
mov si, WELCOME_STRING
call print_string
mov [ BOOT_DRIVE ], dl
mov bp , 0x8000
mov sp , bp
mov bx , 0x9000
mov dh , 5
mov dl , [ BOOT_DRIVE ]
call disk_load
mov dx , [0x9000]
call print_hex
mov dx , [0x9000 + 512]
call print_hex
print_string:
pusha
xor bx,bx
call Next
popa
ret
Next:
mov al, byte [si + bx]
int 0x10
inc bx
or al,al
jnz Next
ret
%include "D:\KOS\disk-load.asm"
%include "D:\KOS\print-hex.asm"
WELCOME_STRING:
db "Booting",0
HEX_OUT : db '0x0000' , 0
BOOT_DRIVE : db 0
jmp $
times 510 -( $ - $$ ) db 0
dw 0xaa55
times 256 dw 0xdada
times 2000 dw 0xface
And here is disk-load.asm:
disk_load :
push dx
mov ah , 0x02
mov al , 0x03
mov ch , 0x00
mov dh , 0x00
mov cl , 0x02
mov bx, 0x00
mov es, bx
mov bx, 0x7c00 + 512
int 0x13
jc disk_error
cmp dh , al
jne disk_error
pop dx
ret
; int 0x13
; jc disk_error
; pop dx
; cmp dh , al
; jne disk_error
; ret
disk_error :
mov si , DISK_ERROR_MSG
call print_string
; Variables
DISK_ERROR_MSG db 'Disk read error!' , 0
And lastly, print-hex.asm, however, even when the calls to print_hex
are removed, the problem persists, so the issue probably isn't here:
print_hex:
pusha
mov si, HEX_OUT + 2
next_character:
mov bx, dx
and bx, 0xf000
shr bx, 4
add bh, 0x30
cmp bh, 0x39
jg add_7
add_character_hex:
mov al, bh
mov [si], bh
inc si
shl dx, 4
or dx, dx
jnz next_character
mov si, HEX_OUT
call print_string
popa
ret
add_7:
add bh, 0x7
jmp add_character_hex
I have combed through multiple answers which seem to have the same problem, but unfortunately, none have worked, so I'm making another question with my own code. Why is the disk not loading properly, and how do I fix this?
Thanks in advance
NB I am on windows, so some functionality of QEmu is removed for me