TITLE : INTERRUPT 25 & 26 - ABSOLUTE DISK READ AND WRITE
END PAGEHEADING
The following example routines are public domain programs that have been uploaded to our Forum on CompuServe. As a courtesy to our users that do not have immediate access to CompuServe, Technical Support distributes these routines free of charge.
However, because these routines are public domain programs, not developed by Borland International, we are unable to provide any technical support or assistance using these routines. If you need assistance using these routines, or are experiencing difficulties, we recommend that you log onto CompuServe and request assistance from the Forum members that developed these routines.
Turbo Pascal's Intr procedure cannot call MS-DOS interrupts 25H and 26H because they do not leave the CPU flags on the stack. This set of functions allows you to call those interrupts, which are Absolute Disk Read and Absolute Disk Write, by using the following functions ReadSectors and WriteSectors, respectively.
Both functions are called with the same parameters:
Buffer: a buffer large enough to hold NumberSectors 512 byte sectors.
Drive: the drive number. 0 is A:, 1 is B:, and so on.
NumberSectors: the number of sectors to transfer.
LogicalSector: the first logical sector number to transfer.
Be sure that the Buffer is large enough to hold 512 times NumberSectors bytes of data. Failure to do so will surely lead to bugs that are difficult to solve.
The integer return value is the error code returned by MS-DOS. "0" indicates a successful transfer, all other values are errors. See a DOS Technical Reference Manual for translations.
A small sample program is provided. It is a minimal disk editor
and is intended as an example only, though it provides the basis for a complete disk editor/utility. The example is commented out -- you must remove the line with the "(*" on it.
USE WITH CAUTION!
}
@newpage
{$C-}
{ Remove the leading * for better keyboard response in the example program }