Page 1 of 1

Error code 1 when using INT13h, AH=42h

Posted: Sun Dec 19, 2010 3:23 pm
by bytbox
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

[SOLVED] Re: Error code 1 when using INT13h, AH=42h

Posted: Sun Dec 19, 2010 4:56 pm
by bytbox
Solved. There wasn't a full sector in my hard disk image. Sorry for the noise.

Re: [SOLVED] Re: Error code 1 when using INT13h, AH=42h

Posted: Sun Dec 19, 2010 9:04 pm
by Brendan
Hi,
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

Re: [SOLVED] Re: Error code 1 when using INT13h, AH=42h

Posted: Sun Dec 19, 2010 9:09 pm
by bytbox
Brendan wrote:It's fairly amazing that your code actually works,
Agreed.
considering that you never set DS (needed for the address of the DAP in "DS:SI" and other things),
Oops. It should be set to 0, right?
don't setup a stack,
Oh. I need that for call, don't I?
disable IRQs for no reason
Any reason not too? I think it doesn't make a difference until you actually want to use them.
and are calculating the address of the DAP manually instead of using a label... ;)
Oops.

Thanks!