Error code 1 when using INT13h, AH=42h
Posted: Sun Dec 19, 2010 3:23 pm
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?
Code: Select all
[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