Provides a direct linkage to the MS-DOS BIOS module to write data from memory to a logical disk sector.
Call with:
For access to partitions <= 32 MB
AL = drive number (0 = A, 1 = B, etc)
CX = number of sectors to write
DX = starting sector number
DS:BX = segment:offset of buffer
For access to partitions > 32 MB (MS-DOS 4.0 and later)
AL = drive number (0 = A, 1 = B, etc)
CX = -1
DS:BX = segment:offset of parameter block (see Notes)
Returns:
If function successful
Carry flag = clear
If function unsuccessful
Carry flag = set
AX = error code (see Notes)
Notes:
All registers except the segment registers may be destroyed.
When this function returns, the CPU flags originally pushed onto the stack by the INT 26H instruction are still on the stack. The stack must be cleared by a POPF or ADD SP,2 to prevent uncontrolled stack growth and to make accessible any other values that were pushed on the stack before the call to INT 26H.
Logical sector numbers are obtained by numbering each disk sector sequentially from cylinder 0, head 0, sector 1, and continuing until the last sector on the disk is counted. The head number is incremented before the track number. Logically adjacent sectors may not be physically adjacent, due to interleaving that occurs at the device-adapter level for some disk types.
The error code is interpreted as follows: The lower byte (AL) is the same error code that is returned in the lower byte of DI when an Int 24H is issued. The upper byte (AH) contains:
01H if bad command 02H if bad address mark 03H if write-protect fault 04H if requested sector not found 08H if direct memory access (DMA) failure 10H if data error (bad CRC) 20H if controller failed 40H if seek operation failed 80H if attachment failed to respond
[4.0+] When accessing partitions larger than 32 MB under MS-DOS version 4, this function uses a parameter block with the following format:
Bytes Description 00H—03H 32-bit sector number 04H—05H number of sectors to read 06H—07H offset of buffer 08H—09H segment of buffer
Example:
Write the contents of the memory area named buff into logical sector 3 of drive C.
Warning: Verbatim use of the following code could damage the file system on your fixed disk. There is, unfortunately, no way to provide a really safe example of this function.
buff db 512 dup (?) ; contains data for write
.
.
.
mov al,2 ; drive C
mov cx,1 ; number of sectors
mov dx,3 ; beginning sector number
mov bx,seg buff ; buffer address
mov ds,bx
mov bx,offset buff
int 26h ; request disk write
jc error ; jump if write failed
add sp,2 ; clear stack
.
.
.