News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Extended int 13h

Started by AeroASM, May 05, 2005, 11:23:28 AM

Previous topic - Next topic

AeroASM

Is this code snippet right?


;LBA in esi, destination address in di, number of sectors in cx
ReadSectors:
mov [DiskAddressPacket+2h],cx
mov [DiskAddressPacket+4h],di
mov [DiskAddressPacket+8h],esi
mov ah,42h
mov dl,[bBootDrive]
mov si,DiskAddressPacket
int 13h
ret
DiskAddressPacket:
db 10h
db 0h
dw 0h
dd 0h
dq 0h


The reason I have not tested it myself is that my computer takes ages to reboot and I am also in the middle of typing a coursework essay.

MichaelW

It looks OK as far as it goes, but it does not check the carry flag on return (CF set on error). And to reliably access a diskette (or other drive that may not be spinning when the call is made) you should make several tries, resetting the disk between tries, before you accept an error return.
eschew obfuscation

AeroASM

Is three tries enough for floppy and one try for HDD? Also the bit I really wanted to check was that when writing a far pointer ds:di you first write di, then ds.

Thanks

MichaelW

I code for four tries and use the same code for all disks. I differentiate between HDD and floppy only for the code that resets the disk. You need to check the error return for a HDD anyway, so using the same code for both does not slow anything down. The function expects a far pointer to the disk address packet in DS:SI so the proper order of the address components in memory does not matter here. For storage in memory the segment should be in the high-order word, so if you were passing a far pointer on the stack you would push the segment first, followed by the offset.
eschew obfuscation