Error code 1 when using INT13h, AH=42h

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.
Post Reply
bytbox
Posts: 11
Joined: Mon May 10, 2010 8:01 pm

Error code 1 when using INT13h, AH=42h

Post 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
bytbox
Posts: 11
Joined: Mon May 10, 2010 8:01 pm

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

Post by bytbox »

Solved. There wasn't a full sector in my hard disk image. Sorry for the noise.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

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

Post 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
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.
bytbox
Posts: 11
Joined: Mon May 10, 2010 8:01 pm

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

Post 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!
Post Reply