home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_25_1988_Transactor_Publishing.d64
/
whereis.asm
< prev
next >
Wrap
Assembly Source File
|
2023-02-26
|
10KB
|
246 lines
;
; WHEREIS (C) 1988 ADAM HERST
;
; WHERE IS THE MATCH TO THE FILE SPECIFICATION ON COMMAND LINE
; EXPAND WILD CARDS
; SEARCH DRIVE IF SPECIFIED OR SEARCH ALL DRIVES IN DRIVE PATH
; SEARCH ALL USER AREAS
; RETURN THE DRIVE SPECIFICATION IN THE FORM duu:FILENAME.TYP
; SET PROGRAM RETURN CODE TO UNSUCCESSFUL IF NO MATCH FOUND
;
; bdos SERVICES
cONoUT EQU 2H ; PRINT CHARACTER
pRsTR EQU 9H ; PRINT STRING
vERnUM EQU 0CH ; RETURN CPM VERSION NUMBER
sRCHf EQU 11H ; SEARCH FOR FIRST FILE NAME
sRCHn EQU 12H ; SEARCH FOR NEXT FILE NAME
cURdRV EQU 19H ; GET CURRENT DRIVE CODE
sETdMA EQU 1AH ; SET DMA BUFFER
gETuSR EQU 20H ; GET/SET USER NUMBER
gETsCB EQU 31H ; GET/SET SCB
rcODE EQU 06CH ; GET/SET PROGRAM RETURN CODE
; SYSTEM POINTERS
fcb EQU 5CH ; fcb BUFFER POINTER
dma EQU 400H ; dma BUFFER POINTER
bdos EQU 5H ; bdos FUNCTION POINTER
; SYMBOLS
cr EQU 0DH ; ASCII CARRIAGE RETURN
lf EQU 0AH ; ASCII LINE FEED
rcode0 EQU 0000H ; SUCCESSFUL RETURN CODE
rcode1 EQU 0FF01H ; USER UNSUCCESSFUL RETURN CODE
ORG 100H
; EXIT WITH MESSAGE IF NOT CPM 3.0
MVI C,vERnUM
CALL bdos
ORA A
JNZ iscpm3
MVI C,pRsTR
LXI D,iscpm2
CALL bdos
RET
iscpm2 DB 'WHEREIS REQUIRES cp/m 3.0',cr,lf,'$'
; SET DMA BUFFER
iscpm3 MVI C,sETdMA
LXI D,dma
CALL bdos
; SET RETURN CODE TO UNSUCCESSFUL
MVI C,rcode
LXI D,rcode1
CALL bdos
; CHECK IF A DRIVE IS SPECIFIED FOR SEARCH
LXI H,fcb ; POINT TO DRIVE CODE IN FCB
MOV A,M ; GET DRIVE CODE FROM FCB
ORA A ; IS IT THE DEFAULT DRIVE CODE?
JZ drive ; YES SO START SEARCHING DRIVE PATH
LXI H,drvoff ; POINT TO OFFSET VALUE FOR DRIVE PATH IN SUBROUTINE
MVI M,04FH ; SET OFFSET TO END OF DRIVE PATH TO FORCE AN EXIT
JMP user ; SEARCH USER AREAS
; SEARCH DRIVES IN DRIVE PATH
drive CALL pathf ; GET FIRST DRIVE IN PATH, LEAVE IN A
nodrv CPI 0H ; IS THERE A DRIVE IN THE PATH?
RZ ; NO SO EXIT
LXI H,fCB ; POINT TO DRIVE CODE IN FCB
MOV M,A ; PUT DRIVE CODE IN FCB
; SEARCH USER AREAS
user MVI C,gETuSR ; START AT USER AREA 0
MVI E,0H
CALL bdos
; SEARCH FOR FIRST MATCH TO THE FILE NAME IN THE fcb
file MVI C,sRCHf
LXI D,fcb
CALL bdos
; CHECK RETURN STATUS
CPI 0FFH ; FOUND FILE?
JZ nxtusr ; NO SO SET NEXT USER NUMBER
CALL pfspec ; YES SO PRINT FILESPEC
; SEARCH FOR NEXT MATCH IN THIS USER AREA
nxtfil MVI C,sRCHn
LXI D,fcb
CALL bdos
; CHECK RETURN STATUS
CPI 0FFH ; FOUND FILE?
JZ nxtusr ; NO SO SET NEXT USER NUMBER
CALL pfspec ; YES SO PRINT FILESPEC
; DO NEXT FILE
JMP nxtfil
; DO NEXT USER AREA
nxtusr MVI C,gETuSR
MVI E,0FFH ; GET USER NUMBER FROM SYSTEM
CALL bdos
INR A ; INCREMENT USER NUMBER
CPI 10H ; IS IT USER NUMBER 16?
JZ nxtdrv ; YES SO DO NEXT DRIVE IN PATH
MVI C,gETuSR
MOV E,A ; SET NEW USER NUMBER
CALL bdos
JMP file ; SEARCH THE NEXT USER AREA FOR FIRST FILE
; DO NEXT DRIVE IN PATH
nxtdrv CALL pathn ; GET NEXT DRIVE CODE, LEAVE IN A
JMP nodrv ; SEARCH THE DRIVE IF THERE IS ONE
; CREATE AND PRINT THE FILESPEC OF DMA ENTRY IN A
pfspec
; DO USER NUMBER
LXI H,dma ; POINT TO USER NUMBER IN FIRST ENTRY
MVI B,0H ; ENTRY COUNTER TO 0
entry CMP B ; IS IT THE RIGHT DMA ENTRY?
JZ number ; YES SO PUT USER NUMBER IN FILESPEC BUFFER
LXI D,20H ; POINT TO USER NUMBER NEXT ENTRY
DAD D
INR B ; INCREMENT ENTRY COUNTER
JMP entry ; CHECK IF THE RIGHT ENTRY
number MOV A,M ; GET USER NUMBER FROM DMA ENTRY
CPI 10D ; IS IT LESS THAN 10
JNC one ; YES SO 1 AS FIRST DIGIT IN USER NUMBER
MVI A,'0' ; 0 AS FIRST DIGIT IN USER NUMBER
STA fspec+1
JMP second ; DO SECOND DIGIT IN USER NUMBER
one MVI A,'1' ; PUT A 1 IN FILESPEC BUFFER
STA fspec+1
second MOV A,M ; GET USER NUMBER FROM FILE ENTRY IN dma BUFFER
CPI 10D ; IS IT LESS THAN 10
JC nosub ; NO SO DON'T SUBTRACT
SUI 10 ; SUBTRACT THE TEN
nosub ADI 30H ; MAKE IT PRINTABLE
STA fspec+2 ; PUT IT IN THE FILESPEC BUFFER
; DO FILENAME
; COPY FILE NAME FROM DMA BUFFER TO FILESPEC BUFFER
INX H ; POINT TO FILENAME IN CURRENT ENTRY
LXI D,fspec+4H ; POINT TO FILENAME IN FILESPEC BUFFER
MVI B,8H ; SET COUNTER FOR FILENAME LENGTH
fname MOV A,M
STAX D
INX H
INX D
DCR B
JNZ fname
MVI B,3H ; SET COUNTER FOR FILETYPE LENGTH
INX D ; POINT TO FILETYPE IN FILESPEC BUFFER
ftype MOV A,M
STAX D
INX H
INX D
Dcr B
JNZ ftype
; DO DRIVE LETTER
LXI H,fcb ; POINT TO DRIVE CODE IN FCB
MOV A,M ; GET THE DRIVE CODE
ADI 40H ; MAKE IT PRINTABLE
LXI H,fspec ; POINT TO DRIVE CODE IN FILESPEC BUFFER
MOV M,A ; PUT DRIVE CODE IN FILESPEC BUFFER
; PRINT THE FILESPEC
MVI C,pRsTR
LXI D,fspec
CALL bdos
; SET RETURN CODE TO SUCCESSFUL
MVI C,rcODE
LXI D,rcode0
CALL bdos
; RETURN FROM pfspec
RET
; RETURN THE NEXT DRIVE IN THE DRIVE PATH IN A
;
; INITIALIZE FOR FIRST DRIVE IN PATH
pathf MVI C,cURdRV ; GET CURRENT DRIVE CODE
CALL bdos
INR A ; ADD DRIVE CODE OFFSET
LXI H,drvflg ; POINT TO DRIVE FLAG
MOV M,A ; SET FLAG, LOW BITS TO DRIVE CODE, HIGH BITS TO 0
LXI H,drvoff ; POINT TO OFFSET OF CURRENT DRIVE IN PATH
MVI M,4BH ; SET OFFSET TO FIRST DRIVE IN PATH - 1
; GET NEXT DRIVE IN PATH
pathn LXI H,drvoff ; POINT TO SCB OFFSET VALUE FOR PREVIOUS DRIVE
MOV A,M ; GET THE OFFSET
INR A ; SET OFFSET FOR CURRENT DRIVE
MOV M,A ; PUT OFFSET VALUE OF CURRENT DRIVE
CPI 50H ; IS CURRENT OFFSET POINTING PAST LAST DRIVE IN PATH?
JZ retend ; YES SO RETURN
LXI H,scbpb ; POINT TO OFFSET IN SCB PARAMETER BLOCK
MOV M,A ; PUT OFFSET OF CURRENT DRIVE IN SCBPB OFFSET
INX H ; POINT TO GET/SET CODE IN SCBPB
MVI M,0H ; SET FOR GET OPERATION
MVI C,gETsCB ; GET THE CURRENT DRIVE IN THE DRIVE PATH
LXI D,scbpb ; POINT TO SCB PARAMETER BLOCK
CALL bdos
CPI 0FFH ; IS IT THE END OF THE PATH?
JZ retend ; YES SO RETURN NO MORE DRIVES CODE
MOV B,A ; STORE CURRENT DRIVE CODE FROM PATH
CPI 0H ; IS IT THE DEFAULT DRIVE CODE?
JZ chkflg ; YES SO CHECK IF DEFAULT DRIVE ALREADY RETURNED
LXI D,DRVFLG ; POINT TO THE DRIVE FLAG
LDAX D ; GET DRIVE FLAG
ANI 0FH ; MASK OFF DEFAULT DRIVE RETURNED BITS
CMP B ; IS IT THE DRIVE CODE OF THE DEFAULT DRIVE?
JNZ retdrv ; NO SO RETURN DRIVE CODE
; CHECK IF DEFAULT DRIVE HAS ALREADY BEEN RETURNED
chkflg LXI D,drvflg ; POINT TO DRIVE FLAG
LDAX D ; GET DRIVE FLAG
ANI 0F0H ; MASK OFF DRIVE CODE
CPI 0F0H ; HAS IT ALREADY BEEN SEARCHED?
JZ pathn ; YES SO GET NEXT DRIVE IN PATH
LDAX D ; GET DRIVE FLAG, SEARCHED BITS ARE ALREADY 0
MOV B,A ; STORE DRIVE CODE OF CURRENT DRIVE
ORI 0F0H ; MASK ON DEFAULT RETURNED FLAG TO RETURNED (0FH)
STAX D ; PUT DEFAULT RETURNED FLAG IN DRIVE FLAG
; RETURN DRIVE CODE OF CURRENT DRIVE IN A
retdrv MOV A,B ; LEAVE THE DRIVE CODE IN A
RET ;
retend MVI A,0H ; LEAVE NO MORE DRIVES CODE IN A
RET
; exit
exit RET
; FILEPEC BUFFER
fspec DB ' : . ',cr,lf,'$'
;
; 'WHERE' VERSION NUMBER
where DB 'V1.2$'
;
; SCB PARAMETER BLOCK
scbpb
scboff DB ' ' ; OFFSET BYTE, SET TO START OF DRIVE PATH - 1
scbcod DB ' ' ; GET/SET CODE
scbval DW ' ' ; BYTE OR WORD VALUE FOR SET OPERATIONS
;
; DRIVE FLAG
drvflg DB ' ' ; HIGH NYBBLE = 0H, DEFAULT NOT SEARCHED
; = fH, SEARCHED
; LOW NYBBLE = DEFAULT DRIVE DRIVE CODE
;
; SCB OFFSET FOR CURRENT DRIVE IN DRIVE PATH
drvoff DB ' '
END