Page 1 of 1

A quick newbie question on int 0x13 ext read

Posted: Thu Jun 17, 2010 10:34 am
by icecoder
I'm trying a new approach to int 0x13 (just to learn more about the way the system works): using stack to create a DAP..

Assuming that DL contains the disk number, AX contains the address of the bootable entry in PT, DS is updated to the right segment and the stack is correctly set, this is the code:

Code: Select all

push DWORD 0x00000000
add ax, 0x0008
mov si, ax
push DWORD [ds:(si)]
push DWORD 0x00007c00
push WORD 0x0001
push WORD 0x0010
push ss
pop ds
mov si, sp
mov sp, bp
mov ah, 0x42
int 0x13
As you can see: I push the dap structure onto the stack, update DS:SI in order to point to it, DL is already set, then set AX to 0x42 and call int 0x13

the result is error 0x01 in AH and obviously CF set. No sectors are transferred.
I checked the stack trace endlessly and it is ok, the partition table is ok too.. I cannot figure out what I'm missing...

This is the stack trace portion of the disk address packet:

Code: Select all

   0x000079ea:	 10 00	adc    %al,(%bx,%si)
   0x000079ec:	 01 00	add    %ax,(%bx,%si)
   0x000079ee:	 00 7c 00	add    %bh,0x0(%si)
   0x000079f1:	 00 00	add    %al,(%bx,%si)
   0x000079f3:	 08 00	or     %al,(%bx,%si)
   0x000079f5:	 00 00	add    %al,(%bx,%si)
   0x000079f7:	 00 00	add    %al,(%bx,%si)
   0x000079f9:	 00 a0 07 be	add    %ah,-0x41f9(%bx,%si)


Re: A quick newbie question on int 0x13 ext read

Posted: Thu Jun 17, 2010 11:27 am
by Ready4Dis
What device are you trying to read. Extended reads doesn't work with floppies (at least in bochs i know). My boot loader that checks to see if the device supports them or not, if it does, it uses it, if not it uses normal reads. Kind of a shame to have to use both (and means you need more code to fit in an already tight space), but it's the only way to support small and large drives at the same time. If that wasn't your issue, let us know and I can try to help when i get home (at work now) and have access to my code.

Re: A quick newbie question on int 0x13 ext read

Posted: Thu Jun 17, 2010 11:32 am
by icecoder
Ready4Dis wrote:What device are you trying to read. Extended reads doesn't work with floppies (at least in bochs i know). My boot loader that checks to see if the device supports them or not, if it does, it uses it, if not it uses normal reads. Kind of a shame to have to use both (and means you need more code to fit in an already tight space), but it's the only way to support small and large drives at the same time. If that wasn't your issue, let us know and I can try to help when i get home (at work now) and have access to my code.
It's a hard drive, DL contains 0x80 as set by the bios..

Re: A quick newbie question on int 0x13 ext read

Posted: Thu Jun 17, 2010 12:03 pm
by M2004
Some int13h extesion implementations are actually stub so you need make sure that
your hardware really supports the extended read command.

Regards
Mac2004

Re: A quick newbie question on int 0x13 ext read

Posted: Thu Jun 17, 2010 12:07 pm
by icecoder
mac2004 wrote:Some int13h extesion implementations are actually stub so you need make sure that
your hardware really supports the extended read command.

Regards
Mac2004
I forgot to say I'm using qemu 0.12.4 to emulate the machine, and already checked for the extensions, which are obviously present.

Re: A quick newbie question on int 0x13 ext read

Posted: Thu Jun 17, 2010 12:57 pm
by bewing
Some BIOSes / emulators require that the DAP be aligned on a 4-byte boundary. Yours is on a 2 byte boundary. Push an extra word before you do the DWORD 0 push, and see what happens.

Re: A quick newbie question on int 0x13 ext read

Posted: Thu Jun 17, 2010 1:04 pm
by icecoder
bewing wrote:Some BIOSes / emulators require that the DAP be aligned on a 4-byte boundary. Yours is on a 2 byte boundary. Push an extra word before you do the DWORD 0 push, and see what happens.
Same result as before.. CF set, AH 0x01

Re: A quick newbie question on int 0x13 ext read

Posted: Sat Jun 19, 2010 6:09 pm
by icecoder
Resolved.

The problem was the "mov sp, bp" before calling int 0x13. BP pointed just before the DAP, so int 0x13 usage of stack overridden the whole data. I hope this will be useful to someone else.