Page 1 of 1

BIOS INT 13H extension read

Posted: Sun Jun 06, 2010 8:52 am
by lemonyii
i've make sure ext int 13h is supported. and i use a usb TF card with FAT32 file system as boot disk.
surely the bootsect is loaded and started up. but then i found it can't read following sectors correctly.
and these are all on real machine(very new).

Code: Select all

DAP:
	PacketSize:		db	0
	Reserved:		db	0
	BlockCount:		dw	0
	BufferAddr:		dd	0	; (segment:offset) 
	BlockNum:		dd	0	
					dd	0

readsectors:	;read cx sectors start at eax to edi
	mov		byte [PacketSize],16
	mov		[BlockCount],cx
	mov		[BufferAddr],di
	shr		edi,4
	and		di,0xf000
	mov		[BufferAddr+16],di
	mov		[BlockNum],eax
	.read:
	mov		ah,0x42
	mov		dl,[BS_DrvNum]
	mov		di,DAP      ;maybe    mov si,DAP?
	int		0x13
	jc		fail
	ret
	fail:
	mov		si,MSGDSKERR
	call	printf
	jmp $
first, it doesn't print message MSGDSKERR,so maybe no fault in int call.
second, i thought it should be mov si,DAP(a document metioned mostly DI,but one key place is SI)., but strange on and off on screen when i use it
third, does the SEG:OFF mean the lower 16 bits is offset and the higher segment?(i think and did so)
least possibility, BlockNum = 0 means the bootsect, and the bonduary is 64k not 32k,right?
thanks,
lemonyii

Re: BIOS INT 13H extension read

Posted: Sun Jun 06, 2010 10:54 am
by Firestryke31
I found you need to make sure the packet is 4-byte aligned or some implementations won't work (i.e. Bochs, and probably some real computers as well). Also, for the SEG:OFF I am pretty sure it needs to be dw Off, dw Seg (or as you're doing it, 0xSSSSOOOO as a dword).

Re: BIOS INT 13H extension read

Posted: Sun Jun 06, 2010 10:24 pm
by lemonyii
4-byte aligned? i'll try.
and i've make sure the machine support ext13h through ah=0x41.
thx

Re: BIOS INT 13H extension read

Posted: Sun Jun 06, 2010 11:37 pm
by geppyfx
Yes, I do see some clear errors along with undefined registers.
http://www.ctyme.com/intr/rb-0708.htm

Re: BIOS INT 13H extension read

Posted: Sun Jun 06, 2010 11:58 pm
by geppyfx
lemonyii wrote:i thought it should be mov si,DAP
You thought correctly.
BlockNum = 0 means the bootsect
yes, master bootsector (MBR)is at LBA0. But LBA block size maybe larger than 512bait - rare(very) but happens (USB ZIP).
and the boundary is 64k not 32k,right
boundary is limited by destination segment which is 64KB. Some modern bioses can go over 64KB boundary some can't.
True boundary for many BIOSes is limited by single LBA block size. You can't read more than one LBA block per single int13 call.

Re: BIOS INT 13H extension read

Posted: Mon Jun 07, 2010 9:57 am
by M2004
Have you checked that your bios actually supports int13h extended read command?
Some bios int13h extensions implementations may be stub?

regards
Mac2004

Re: BIOS INT 13H extension read

Posted: Thu Jun 10, 2010 10:30 pm
by lemonyii
I found you need to make sure the packet is 4-byte aligned
that's the point.
thank you and sorry for replying so late.