absread and abswrite Functions
These Functions have been defined in Dos.h. The absread function reads absolute disk sectors and the abswrite function writes absolute disk sectors. The function absread uses DOS interrupt 0x25 to read specific disk sectors and the function abswrite uses DOS interrupt 0x26 to write specific disk sectors.
Absolute read or write operations proceeds in sequential manner by incrementing sector(s) step by step and are completely free of the head and track numbers etc. it is the job of BIOS of the computer to translate the absolute sectors to the respective track, Head and Sector numbers.
Absolute read and write operations are recommended in such programs where we are going to perform read/write operation on the entire disk and we want to avoid extra coding and looping in our program to increase the speed of the program to fastest.
Both of the functions absread and abswrite, ignore the logical structure of a disk and pay no attention to files, FATs, or directories. These functions directly perform absolute read and absolute write operation on the surface of the disk, This is the reason that if used improperly, abswrite can overwrite files, directories, and FATs.
The declaration of the absread function is as follows:
int absread(int drive, int nsects, long lsect,
void *buffer);
and the abswrite function is declared as follows:
int abswrite(int drive, int nsects, long lsect,
void *buffer);
Where the meaning of parameters is as follows:
Param. |
What It Is/Does |
drive |
Drive number to read (or write): 0 = A, 1 = B, etc. |
nsects |
Number of sectors to read (or write) |
lsect |
Beginning logical sector number |
buffer |
Memory address where the data is to be read (or written) |
On success, both of the functions return 0. When there is any error, both return -1 and set error no. to the value of the AX register returned by the system call.
The number of sectors for read or write operation is limited to 64K or the size of the buffer, whichever is smaller. However we will learn the use of Huge memory in next chapters to exceed out of the memory limit 64K, to develop a very fast program. |
|