home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
d
/
drcpas10.zip
/
ABSDISK.ASM
next >
Wrap
Assembly Source File
|
1992-07-30
|
9KB
|
210 lines
IDEAL
MODEL TPASCAL
DATASEG
EXTRN dosver:WORD
EXTRN abserror:WORD
STRUC pack
sec dd ?
num dw ?
buf dd ?
ENDS
packet pack ?
dummy db 20h dup (?)
CODESEG
IF 0
----------25---------------------------------
INT 25 - DOS 1+ - ABSOLUTE DISK READ (except partitions > 32M)
AL = drive number (00h = A:, 01h = B:, etc)
CX = number of sectors to read
DX = starting logical sector number (0000h - highest sector on drive)
DS:BX -> buffer for data
Return: CF clear if successful
CF set on error
AH = status
80h device failed to respond (timeout)
40h seek operation failed
20h controller failed
10h data error (bad CRC)
08h DMA failure
04h requested sector not found
03h write-protected disk (INT 26 only)
02h bad address mark
01h bad command
AL = error code (same as passed to INT 24 in DI)
may destroy all other registers except segment registers
Notes: original flags are left on stack, and must be popped by caller
this call bypasses the DOS filesystem
BUG: DOS 3.1 through 3.3 set the word at ES:[BP+1Eh] to FFFFh if AL is an
invalid drive number
SeeAlso: INT 13/AH=02h,INT 26
----------25---------------------------------
INT 25 - DOS 3.31+ - ABSOLUTE DISK READ (>32M hard-disk partition)
AL = drive number (0=A, 1=B, etc)
CX = FFFFh
DS:BX -> disk read packet (see below)
Return: same as above
Notes: partition is potentially >32M (and requires this form of the call) if
bit 1 of device attribute word in device driver is set
original flags are left on stack, and must be removed by caller
this call bypasses the DOS filesystem
SeeAlso: INT 13/AH=02h,INT 26
Format of disk read packet:
Offset Size Description
00h DWORD sector number
04h WORD number of sectors to read
06h DWORD transfer address
ENDIF
PROC absread FAR drive:BYTE, sector:DWORD, numsecs:WORD, buffer:FAR PTR
PUBLIC absread
push ds ; save ds
mov ax, [dosver] ; get DOS version
cmp al, 3 ; after version 3?
jg @@extended ; uses extended partitions
cmp ah, 30 ; after 3.30?
jg @@extended ; uses extended partitions
@@normal:
mov cx, [numsecs] ; number of sectors to read
les ax, [sector] ; sector number to read
or ax, ax ; high word should be zero
jz @@okay ; on normal partitions
mov ax, 0408h ; else return with
jmp short @@error ; sector not found error
@@okay:
mov dx, es ; low word of sector number
lds bx, [buffer] ; ds:bx points to buffer
jmp short @@both ; skip past extended setup
@@extended:
mov bx, OFFSET packet ; ds:bx points to packet
mov cx, 0FFFFh ; -1 indicates extended partitions
les ax, [sector]
mov dx, es
mov [WORD packet.sec], ax
mov [(WORD packet.sec)+2], dx
les ax, [buffer]
mov dx, es
mov [WORD packet.buf], ax
mov [(WORD packet.buf)+2], dx
mov ax, [numsecs]
mov [packet.num], ax ; set up data packet
@@both:
mov al, [drive] ; drive number (0 = A:, 1 = B:, etc.)
push ds ; load es
pop es ; with ds
push bp ; save bp
mov bp, OFFSET dummy ; es:bp points to dummy
int 25h ; absolute disk read
jc short @@error ; was there an error?
@@noerror:
xor ax, ax ; zero the ax register
@@error:
add sp, 2 ; clear flags off stack
pop bp ; restore bp
pop ds ; restore ds
mov [abserror], ax ; error code in ax
ret ; and return
ENDP absread
IF 0
----------26---------------------------------
INT 26 - DOS 1+ - ABSOLUTE DISK WRITE (except partitions > 32M)
AL = drive number (00h = A:, 01h = B:, etc)
CX = number of sectors to write
DX = starting logical sector number (0000h - highest sector on drive)
DS:BX -> data to write
Return: CF clear if successful
CF set on error
AH = status
80h device failed to respond (timeout)
40h seek operation failed
20h controller failed
10h data error (bad CRC)
08h DMA failure
04h requested sector not found
03h write-protected disk (INT 26 only)
02h bad address mark
01h bad command
AL = error code (same as passed to INT 24 in DI)
may destroy all other registers except segment registers
Notes: original flags are left on stack, and must be popped by caller
this call bypasses the DOS filesystem
BUG: DOS 3.1 through 3.3 set the word at ES:[BP+1Eh] to FFFFh if AL is an
invalid drive number
SeeAlso: INT 13/AH=03h,INT 25
----------26---------------------------------
INT 26 - DOS 3.31+ - ABSOLUTE DISK WRITE (>32M hard-disk partition)
AL = drive number (0=A, 1=B, etc)
CX = FFFFh
DS:BX -> disk write packet (see below)
Return: same as above
Notes: partition is potentially >32M (and requires this form of the call) if
bit 1 of device attribute word in device driver is set
original flags are left on stack, and must be removed by caller
this call bypasses the DOS filesystem
SeeAlso: INT 13/AH=03h,INT 25
Format of disk write packet:
Offset Size Description
00h DWORD sector number
04h WORD number of sectors to read
06h DWORD transfer address
ENDIF
PROC abswrite FAR drive:BYTE, sector:DWORD, numsecs:WORD, buffer:FAR PTR
PUBLIC abswrite
push ds ; save ds
mov ax, [dosver] ; get DOS version
cmp al, 3 ; after version 3?
jg @@extended ; uses extended partitions
cmp ah, 30 ; after 3.30?
jg @@extended ; uses extended partitions
@@normal:
mov cx, [numsecs] ; number of sectors to read
les ax, [sector] ; sector number to read
or ax, ax ; high word should be zero
jz @@okay ; on normal partitions
mov ax, 0408h ; else return with
jmp short @@error ; sector not found error
@@okay:
mov dx, es ; low word of sector number
lds bx, [buffer] ; ds:bx points to buffer
jmp short @@both ; skip past extended setup
@@extended:
mov bx, OFFSET packet ; ds:bx points to packet
mov cx, 0FFFFh ; -1 indicates extended partitions
les ax, [sector]
mov dx, es
mov [WORD packet.sec], ax
mov [(WORD packet.sec)+2], dx
les ax, [buffer]
mov dx, es
mov [WORD packet.buf], ax
mov [(WORD packet.buf)+2], dx
mov ax, [numsecs]
mov [packet.num], ax ; set up data packet
@@both:
mov al, [drive] ; drive number (0 = A:, 1 = B:, etc.)
push ds ; load es
pop es ; with ds
push bp ; save bp
mov bp, OFFSET dummy ; es:bp points to dummy
int 26h ; absolute disk write
jc short @@error ; was there an error?
@@noerror:
xor ax, ax ; zero the ax register
@@error:
add sp, 2 ; clear flags off stack
pop bp ; restore bp
pop ds ; restore ds
mov [abserror], ax ; error code in ax
ret ; and return
ENDP
END