home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
_tr_func.asm
< prev
next >
Wrap
Assembly Source File
|
1990-10-21
|
7KB
|
257 lines
; _TR_FUNC.ASM
;
; by Leonard Zerman, Ralph Davis
; modified by Rick Spence
;
; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
;
PUBLIC _GET_DRIVE, _GET_DIR, _SET_DRIVE, _SET_DIR
PUBLIC _FIND_FIRST, _FIND_NEXT, __TR_MKDIR, _GET_DIR2
DGROUP GROUP _DATA
;********************************************************
_DATA SEGMENT WORD PUBLIC 'DATA'
CURR_DIR DB '\',63 DUP (?),0; Storage area for current directory
DTA DB 30 DUP (?) ; Disk Transfer Area for DOS INT 21H
FILENAME DB 13 DUP (?) ; Name of file returned by
; function call 4EH
_DATA ENDS
;********************************************************
;********************************************************
_TR_FUNC_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TR_FUNC_TEXT, DS:_DATA
;------------------------------------------
; get_drive()
;
; Returns current drive as integer
;
; c = get_drive();
;
; int get_drive();
; int c;
;------------------
_GET_DRIVE PROC FAR
MOV AH,19H
INT 21H
XOR AH,AH
RET
_GET_DRIVE ENDP
;------------------------------------------
; __TR_MKDIR()
;
; Creates a directory
; Returns 0 if sucessful else -1;
; status = _tr_mkdir();
; char *ptr;
;------------------
__TR_MKDIR PROC FAR
PUSH BP
MOV BP,SP
PUSH DS
MOV AH,39h
LDS DX,[BP+6]
INT 21H
POP DS
JC ERROR
XOR AX,AX
JMP EXIT
ERROR:
MOV AX,-1
EXIT:
POP BP
RET
__TR_MKDIR ENDP
;------------------------------------------
; get_dir()
;
; Returns current directory as char *
;
; dir = get_dir();
;
; char *get_dir();
; char *dir;
;------------------
_GET_DIR PROC FAR
PUSH SI
PUSH DS
MOV AX,SEG CURR_DIR
MOV DS,AX
MOV AH,47H ; Get current directory
MOV SI,OFFSET DS:CURR_DIR+1 ; Address of return buffer
MOV DL,0 ; Current default drive
INT 21H
MOV DX,DS ; Place segment address of directory
; in DX
MOV AX,SI ; AX now points to directory string
; without '\'
DEC AX ; AX now points to '\', which is
POP DS
POP SI
RET
_GET_DIR ENDP
;------------------------------------------
; get_dir2()
;
; Returns current directory as char *
;
; dir = get_dir2(drivenbr);
;
; char *get_dir2();
; char *dir;
; int drivenbr;
;------------------
_GET_DIR2 PROC FAR
PUSH BP
MOV BP,SP
PUSH SI
PUSH DS
MOV AX,SEG CURR_DIR
MOV DS,AX
MOV AH,47H ; Get current directory
MOV SI,OFFSET DS:CURR_DIR+1 ; Address of return buffer
MOV DX,[BP+6] ; Pick up number of desired drive
INC DX
INT 21H
JC GD2ERROR
MOV DX,DS ; Place segment address of directory
; in DX
MOV AX,SI ; AX now points to directory string
; without '\'
DEC AX ; AX now points to '\', which is
JMP GD2EXIT
GD2ERROR:
XOR DX,DX ; RETURN NULL PTR
XOR AX,AX
GD2EXIT:
POP DS
POP SI
POP BP
RET
_GET_DIR2 ENDP
;-------------------------------------------
; set_drive();
;
; logs onto requested drive
;
; status = set_drive( drive );
;
; int set_drive();
; int status;
; int drive;
;------------------
_SET_DRIVE PROC FAR
PUSH BP
MOV BP,SP
MOV DX,[BP+6] ; Pick up number of desired drive
MOV AH,0EH ; Select Disk function call
INT 21H
XOR AX,AX ; Return 0
POP BP
RET
_SET_DRIVE ENDP
;-------------------------------------------
; set_dir();
;
; changes to requested directory
;
; status = set_dir( directory );
;
; int set_dir();
; int status;
; char *directory;
;------------------
_SET_DIR PROC FAR
PUSH BP
MOV BP,SP
PUSH DS
LDS DX,[BP+6] ; Pick up pointer to desired directory
MOV AH,3BH ; Change directory
INT 21H
JNC SD2
MOV AX,-1 ; Return -1 for error
JMP SHORT SD3
SD2:
XOR AX,AX ; Return 0 for success
SD3:
POP DS
POP BP
RET
_SET_DIR ENDP
;--------------------------------------------
; find_first();
;
; filename = find_first();
;
; char *find_first();
; char *filename;
;------------------
_FIND_FIRST PROC FAR
PUSH BP
MOV BP,SP
PUSH DS ; Save DS
CALL _SET_DTA ; DTA must be set before calling INT 21H
MOV AH,4EH ; Find first matching file
XOR CX,CX ; 0 attribute means all attributes OK
LDS DX,[BP+6] ; Pick up pointer to filename
INT 21H
POP DS ; Restore DS
JNC FF2 ; Carry means error
XOR AX,AX ; Return null pointer if no file found
XOR DX,DX
JMP SHORT FF3
FF2: MOV DX,DS ; Return pointer to filename
MOV AX,OFFSET _DATA:FILENAME
FF3:
POP BP
RET
_FIND_FIRST ENDP
;------------------------------------------------
_FIND_NEXT PROC FAR
PUSH BP
MOV BP,SP
MOV DX,OFFSET _DATA:DTA ; DTA already set by FIND_FIRST
MOV AH,4FH ; Find next matching file
INT 21H
JNC FN2 ; Carry means error
XOR AX,AX ; Return null pointer for error
XOR DX,DX
JMP SHORT FN3
FN2: MOV DX,DS ; Return pointer to filename
MOV AX,OFFSET _DATA:FILENAME
FN3: POP BP
RET
_FIND_NEXT ENDP
;--------------------------------------------
_SET_DTA PROC NEAR
PUSH AX
PUSH DX
MOV DX,OFFSET _DATA:DTA ; Point to our disk transfer area
MOV AH,1AH ; Set DTA function
INT 21H
POP DX
POP AX
RET
_SET_DTA ENDP
;---------------------------------------------
_TR_FUNC_TEXT ENDS
;*******************************************************
END