Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I'm trying to write a simple "bootloader" that reads one sector from hd0. After I call int13h, ah=0x01 (and the error flag is set). I'm using ah=42h (extended read). Running in qemu, no kvm. So... I think that means my DAP is constructed wrong?
[bits 16]
[org 0x7c00]
cli
call Progress
; Assume we're using the first hard disk
mov dl, 0x80
; reset drive
mov ah, 0x00
int 0x13
mov si, 0x7c00
add si, 0x0200
sub si, 18
mov ah, 0x42
int 0x13
mov al, ah
add al, '0'
call PrintCharacter
jc Error
call Progress
hlt
;; print a '.' to the screen
;; Modifies ax, bx
Progress:
mov al, '.'
call PrintCharacter
ret
;; print a single character to the screen from al
;; modifies ah, bx
PrintCharacter:
mov ah, 0x0e
mov bh, 0x00
mov bl, 0x07
int 0x10
ret
Error:
mov al, '!'
call PrintCharacter
hlt
times 512 - 16 - 2 - ($ - $$) db 0
; The DAP: Data Address Packet
db 0x10 ; size of DAP
db 0x00 ; unused
dw 0x01 ; number of sectors to read
dw 0x1000 ; offset of destination buffer
dw 0x0000 ; segment of destination buffer
dq 0x0001 ; where to start reading
dw 0xaa55
bytbox wrote:Solved. There wasn't a full sector in my hard disk image. Sorry for the noise.
It's fairly amazing that your code actually works, considering that you never set DS (needed for the address of the DAP in "DS:SI" and other things), don't setup a stack, disable IRQs for no reason and are calculating the address of the DAP manually instead of using a label...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.