;V2.0 ;CAT.ASM - PERFORMS DIR FUNCTION ON MAST.CAT ;11/??/77 WRITTEN BY WARD CHRISTENSEN ;01/07/78 MODIFY FOR NON-BASIC MASTER CAT ;01/08/78 MODIFY TO SKIP IGNORE FILENAMES ; 01/12/81 WDE MODIFY FOR USER NRS ;TO EXECUTE: ; CAT FILENAME.FILETYPE DISKNAME.DISKTYPE ;COMMAND MAY BE FOLLOWED BY COMMENTS (TITLE) ;MAST.CAT M-U-S-T HAVE IGNORE FILENAMES FIRST ;EG: (NAME.TYPE ; NAME.TYPE ; LASTNAME.TYPE) ORG 100H CALL START DB 'CAT.COM 01/12/81' DB 0DH,0AH,'$' ;PRINT ID MESSAGE START POP D MVI C,PRINT CALL BDOS ;INIT LOCAL STACK LXI H,0 DAD SP SHLD STACK LXI SP,STACK ;SAVE THE NAMES LXI D,FCB+1 LXI H,FNAME MVI B,8 CALL MOVER MVI B,3 CALL MOVER LXI D,FCB+17 ;DISK NAME LXI H,DNAME MVI B,8 CALL MOVER MVI B,3 CALL MOVER ;MOVE 'MAST.CAT' TO FCB LXI D,FCBNAME LXI H,FCB+1 MVI B,8+3+1 CALL MOVE ;SAVE THE COMMAND LINE AS THE TITLE ;ALLOWS 'CAT *.* *.* MM/DD/YY' TYPE TITLE ;FOR HARD COPY LISTINGS LXI D,80H LXI H,TTL0+6 LDAX D ;GET LENGTH ORA A ;NO OPERANDS ON CAT? JZ NOOP INX D MOV B,A ;SET FOR MOVE CALL MOVE NOOP MVI M,'$' ;END OF TITLE ;OPEN MAST.CAT LXI D,FCB MVI C,OPEN CALL BDOS INR A JNZ SKPIGN ;SKIP THE 'TO BE IGNORED' NAMES ;OPEN FAILED CALL ERXIT DB '++UNABLE TO OPEN MAST.CAT$' ;EXIT PRINTING MSG ON TOP OF STACK ERXIT POP D ;GET ERR MSG MVI C,PRINT CALL BDOS ;RESTORE STACK, EXIT EXIT LHLD STACK SPHL RET ; ;SKIP THE IGNORE FILENAMES AT THE HEAD OF MAST.CAT ; SKPIGN CALL RDCHR CPI ')' ;END OF IGNORE? JNZ SKPIGN CALL RDCHR ;GET CR CALL RDCHR ;GET LF JMP NEWPG1 ; NEWPG MVI A,'L'-40H ;FORMS FEED CALL TYPE ;EJECT ;PRINT TITLE NEWPG1 LXI D,TTL0 MVI C,PRINT CALL BDOS CALL CRLF CALL CRLF LXI D,TTL MVI C,PRINT CALL BDOS CALL CRLF ;RESET LINECOUNT MVI A,5 STA LINECT ;MATCH A LINE, PRINT IF IT MATCHES ;EXIT IF KEY PRESSED LOOP MVI C,KSTAT CALL BDOS DCR A JZ EXIT ;MATCH FILENAME LXI D,BUFF ;WHERE TO STORE NAME READ LXI H,FNAME MVI B,8 CALL MATCH JC SKIP ;NAME/TYPE DIDN'T MATCH INX D ;ALLOW FOR '.' ;MATCH FILETYPE MVI B,3 ;TYPE CALL MATCH JC SKIP ;SKIP PAST COMMA ;MATCH DISK'S FILENAME LXI D,BUFF+15 LXI H,DNAME MVI B,8 CALL MATCH JC SKIP INX D ;ALLOW FOR '.' ;MATCH DISK'S FILETYPE (NUMBER) MVI B,3 CALL MATCH ;TYPE JC SKIP INX D ;ALLOW FOR ';' UNG CALL RDCHR CPI ';' JZ UNG STAX D ; ; ;GOT MATCHING NAME ; FNIN LXI H,BUFF ;PRINT MESSAGE UP TO BINARY 0 PRBUF MOV A,M ORA A ;END OF BUFF? JZ EOBUF CALL TYPE INX H JMP PRBUF EOBUF LDA ENTRY INR A ANI 1 STA ENTRY JNZ SKIP CALL CRLF LDA LINECT INR A STA LINECT CPI 58 JC SKIP CALL SKIPLF JMP NEWPG ; SKIP CALL SKIPLF JMP LOOP ;SKIP TO END OF LINE (L/F) SKIPLF CALL RDCHR CPI 0AH ;SKIP TO END JNZ SKIPLF ;OF LINE RET ; ;MATCH ENTRY BY READING CHARS ;STORE IN BUFFER POINTED TO BY DE ;MATCH NAME POINTED TO BY HL ; MATCH CALL RDCHR STAX D CMP M JNZ MAT50 ;CHECK '?' MAT25 INX D INX H DCR B ;MORE? JNZ MATCH MAT40 CALL RDCHR ;EAT TERMINATOR ORA A ;CARRY OFF, SHOWS OK RET ; MAT50 CPI '.' ;END OF NAME? JZ MAT100 CPI ',' ;END OF NAME? JZ MAT100 CPI ';' ;END OF TYPE? JZ MAT100 MOV A,M ;MATCHING '?' CPI '?' JZ MAT25 ;ACCEPT IT MAT75 MVI A,' ' ;PAD STAX D INX D INX H DCR B JNZ MAT75 STC ;SHOW BAD RET MAT100 MOV A,M CPI '?' JZ MAT200 CPI ' ' JNZ MAT75 MAT200 MVI A,' ' STAX D INX D INX H DCR B JNZ MAT100 ORA A ;MATCH RET ; ;READ CHAR FROM DISK ; RDCHR PUSH B PUSH D PUSH H LHLD BUFAD MOV A,H ;TIME TO READ? DCR A JNZ NOREAD LXI D,FCB MVI C,READ CALL BDOS ORA A JZ RDOK CALL ERXIT DB '++READ ERROR OR EARLY EOF$' RDOK LXI H,80H NOREAD MOV A,M ;GET CHAR INX H SHLD BUFAD POP H POP D POP B CPI 'Z'-40H ;EOF? JZ EOF RET ; CRLF MVI A,0DH CALL TYPE MVI A,0AH ; TYPE PUSH B PUSH D PUSH H MOV E,A MVI C,WRCON CALL BDOS POP H POP D POP B RET ; ;MOVER - MOVE CHARS FROM (DE) TO (HL), LENGTH IN (B) ; IF FIRST CHAR = ' ', MOVE ALL '?' ; MOVER LDAX D CPI ' ' JZ QUEST ; ;MOVE CHARS FROM (DE) TO (HL) FOR LENGTH IN (B) ; MOVE LDAX D ;GET A CHAR MOV M,A INX D INX H DCR B JNZ MOVE RET ; ;PAD FILENAME OR TYPE WITH ALL '?' ; QUEST MVI M,'?' INX H INX D DCR B JNZ QUEST RET ; EOF CALL ERXIT DB 0DH,0AH,'L'-40H,'$' DS 50 ;STACK STACK DW 0 FNAME DS 8 FTYPE DS 3 DNAME DS 8 DTYPE DS 3 FCBNAME DB 'MAST CAT',0 ;0 = EXTENT # ENTRY DB 0 ;0/1 = LEFT, RIGHT BUFAD DW 100H ;BUFFER PONTER TTL DB ' NAME DISK U ' DB ' NAME DISK U' DB 0DH,0AH,'$' BUFF DB '............ ............ . ',0 LINECT DB 0 TTL0 DB 'FILES:' ; (COMMAND TITLE MOVED HERE) ; * * * * * * * * * * * * * * * * * * * * * * * * ; * ;BDOS/CBIOS EQUATES (VERSION 5) * ;(WITH UNREFERENCED EQUATES EDITED OUT) * ; * WRCON EQU 2 ; * PRINT EQU 9 ; * KSTAT EQU 11 ;1=KEY PRESSED * OPEN EQU 15 ;0FFH=NOT FOUND * READ EQU 20 ;0=OK, 1=EOF * BDOS EQU 5 ; * FCB EQU 5CH ; * ; * * * * * * * * * * * * * * * * * * * * * * * * END