home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
_tr_isdr.asm
< prev
next >
Wrap
Assembly Source File
|
1990-10-21
|
5KB
|
129 lines
; _TR_ISDR.ASM
;
; by Ralph Davis
; modified by Leonard Zerman
;
; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
;
PUBLIC __TR_ISDR
DGROUP GROUP _DATA
;***************************************************
_DATA SEGMENT WORD PUBLIC 'DATA'
;
FAT DB 1024 DUP (?) ; Buffer for disk read
IS_DOS DB ? ; Flag to indicate whether we use
; INT 25H (DOS) or INT 13H (ROM BIOS)
;
_DATA ENDS
;***************************************************
;***************************************************
_TR_ISDR_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TR_ISDR_TEXT,DS:_DATA
;---------------------------------------------------
;
; Syntax: __ts_isdr( <drive> )
; Return: 1 if drive exists and is ready
; 0 otherwise
;
; Note: This function uses INT 25H (absolute disk read)
; or ROM BIOS INT 13H so as to avoid DOS
; "Abort, Retry, Ignore" messages.
;
;-----------------
__TR_ISDR PROC FAR
PUSH BP ; Save caller's BP
MOV BP,SP ; Address stack through BP
PUSH SI ; Save other registers
PUSH DS
PUSH ES
PUSH DX
LDS BX,[BP+6] ; Get pointer to drive
MOV DL,BYTE PTR [BX] ; drive specifier in DL
AND DL,0DFH ; force to upper-case
CMP DL,'B' ; Greater than drive B?
JG USE_DOS ; Yes, use DOS INT 21H
; Otherwise, use ROM BIOS INT 13H
SUB DL,41H ; convert to binary number
MOV SI,3 ; We try to read the disk three times
; before reporting failure
READ_DISK:
MOV DH,0 ; head number 0
MOV CH,0 ; track number 0
MOV CL,1 ; start with sector number 1
MOV AL,1 ; read 1 sectors
MOV AH,2 ; request disk read
PUSH AX
MOV AX,_DATA ; Point DS and ES to our data segment
MOV DS,AX
MOV ES,AX
POP AX
AND IS_DOS,0 ; Set DOS flag to false
MOV BX,OFFSET FAT ; address of buffer
PUSHF ; Save flags (not necessary, done
; for code compatibility with DOS
; INT 25H)
INT 13H ; read the disk
JNC GOODREAD ; carry flag is error reporter
POPF ; Restore flags
DEC SI ; Try three times if unsuccessful
JNZ READ_DISK
MOV BX,0 ; for FALSE return
PUSH BX ; Save it till we need it
XOR AX,AX ; floppy disk service 0
INT 13h ; reset disk drive
JMP SHORT EXIT
USE_DOS: MOV AL,DL ; Drive letter to AL
SUB AL,41H ; Convert to binary
MOV CX,1 ; Starting sector number
MOV DX,2 ; Read two sectors
PUSH AX
MOV AX,_DATA ; Point DS to our data segment
MOV DS,AX
POP AX
MOV BX,OFFSET FAT ; Point BX to input buffer
OR IS_DOS,0FFH ; Turn on DOS flag
PUSHF ; Save flags--INT 25H doesn't POP them
INT 25H
JNC GOODREAD
POPF ; Restore flags
ADD SP,2 ; Restore stack
MOV BX,0 ; For FALSE return
PUSH BX ; Save it for later
JMP SHORT EXIT
;
GOODREAD:
POPF ; Restore flags
CMP IS_DOS,0FFH ; Did we do INT 25H or INT 13H?
JNE GR_2 ; INT 13H
ADD SP,2 ; Restore stack
GR_2:
MOV BX,1 ; for TRUE return
PUSH BX ; Save it for later
EXIT: CMP IS_DOS,0FFH ; DOS or ROM BIOS?
JNE EXIT_2 ; ROM BIOS
MOV AH,0DH ; Reset disk status if DOS
INT 21H
EXIT_2:
POP BX ; Retrieve TRUE or FALSE result
MOV AX,BX ; Place it in AX ax return value
POP DX
POP ES ; Restore registers
POP DS
POP SI
POP BP
RET
__TR_ISDR ENDP
;-----------------------------------------------------------
_TR_ISDR_TEXT ENDS
;*************************************************************
END