A quick newbie question on int 0x13 ext read

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
icecoder
Posts: 16
Joined: Tue Jun 15, 2010 3:28 am

A quick newbie question on int 0x13 ext read

Post 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)

Ready4Dis
Member
Member
Posts: 571
Joined: Sat Nov 18, 2006 9:11 am

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

Post 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.
icecoder
Posts: 16
Joined: Tue Jun 15, 2010 3:28 am

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

Post 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..
M2004
Member
Member
Posts: 65
Joined: Sun Mar 07, 2010 2:12 am

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

Post 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
icecoder
Posts: 16
Joined: Tue Jun 15, 2010 3:28 am

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

Post 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.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

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

Post 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.
icecoder
Posts: 16
Joined: Tue Jun 15, 2010 3:28 am

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

Post 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
icecoder
Posts: 16
Joined: Tue Jun 15, 2010 3:28 am

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

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