; CDIR - A program to compare directories of two disks. ; ; V1.2 (KP10) Special Kaypro 10-only version for use on hard drive to ; 4/04/86 compare to files on the floppy drive (user 0 only). ; ; Use CDIR12.ASM for non-Kaypro 10 assemblies - I added a ; lot of specific code in this version. ; ; Steve Sanders, TBKUG/DataCOM Super Systems ; (813) 791-1454 or 791-1455 modem 300/1200/2400 ; ;-------------------------------------------------------------------- ; ;Written by: Robert Wilcox ; v1.0 920 N. Washington St. ; Owosso, MI 48867 ; ; v1.1 Fixes and mods by Mark Pulver ; ;-------------------------------------------------------------------- ; ;Operation: ; CDIR will compare the directory of the currently logged du: ; of the Kaypro 10 hard drive against the directory of the ; floppy diskette loaded in drive C. Any matching filenames ; will be displayed in inverse video for easy comparison. ; ;************************************************************************* ; NOTE: User 0 of the floppy drive is ALWAYS selected for comparisons. * ;************************************************************************* ; ; Syntax: ; CDIR compare ALL files to drive C0: ; ; Wild cards (CDIR *.ASM, CDIR test?.as?, etc. are supported. ; ; CDIR ? gives a help message. ; ; Any key pressed while the directory is being printed aborts ; the program. ; ; Program aborts with "NO FILES" message if current du: is empty. ; ; ;------------------------ ; FALSE EQU 0 TRUE EQU NOT FALSE ; ; ; CP/M FUNCTION CODES - PASS IN REGISTER C TO BDOS ; RCCFC EQU 01 ;READ CONSOLE CHARACTER WCCFC EQU 02 ;WRITE CONSOLE CHARACTER WCBFC EQU 09 ;WRITE CONSOLE BUFFER GCSFC EQU 11 ;GET CONSOLE STATUS RESET EQU 13 ;DISK RESET SELDSK EQU 14 ;SELECT DISK SRFFC EQU 17 ;SEARCH FIRST SRNFC EQU 18 ;SEARCH NEXT GETDRV EQU 25 ;GET DRIVE NUMBER CURUSR EQU 32 ;GET USER NUMBER ; ; CP/M ADDRESS EQUATES ; BDOS EQU 0005H ;BDOS ENTRY POINT SFCB EQU 005CH ;SYSTEM FILE CONTROL BLOCK DBUF EQU 0080H ;SYSTEM DISK BUFFER ; ; ASCII EQUATES ; BEL EQU 07H ;BELL LF EQU 0AH ;LINE FEED VT EQU 0BH ;VERTICAL TAB (CTRL-K) CR EQU 0DH ;CARRIAGE RETURN NAK EQU 15H ;CTRL-U CLR EQU 1AH ;CTRL-Z/CLEAR SCREEN ESC EQU 1BH ;ESCAPE EOS EQU '$' ;END OF STRING ; PRTN: EQU 4 ;number of file names on a line ; ;............. ; ; ORG 0100H ;program originate address ; START: LXI H,0 ;begin by saving system DAD SP ;stack pointer and setting SHLD OLDSP ;program stack LXI SP,STACK+64 ; LXI D,MSG0 CALL WASC ;print program title ; savdrv: mvi c,getdrv ;get drive call bdos sta drive ;store for later mvi e,0ffh mvi c,curusr ;get current user call bdos sta user ;store for later ; ckbuf: lda dbuf ;look at dbuf ana a ;see if anything typed after "CDIR" jz makefcb ;if not, make like "CDIR *.*" cpi 2 ;2 characters (" ?") typed? jnz nohelp ;no - lda dbuf+2 ;if yes, was it '?' cpi '?' jnz nohelp lxi d,helpmsg ;if '?' type help message and call wasc ;return to cp/m jmp exit ; makefcb: lxi h,sfcb+1 ;make fcb ????????.??? mvi b,11 all1: mvi m,'?' inx h dcr b jnz all1 ; mvi b,24 ;fill rest with zeroes all2: mvi m,0 inx h dcr b jnz all2 ; nohelp:; ;program continues - - LXI D,MSG2 CALL WASC ;give instructions WAIT: CALL RACC ;wait for CPI ' ' ;space returns JZ DONE ;to CP/M CPI CR JNZ WAIT MVI C,RESET CALL BDOS LXI D,MSG1A CALL WASC ;print header ; lda drive ;print current drive letter adi 'A' mov e,a call output lda user ;and user number mov l,a mvi h,0 mov d,h call prnd2 mvi e,':' call output ; lxi d,msg1b ;finish rest of message call wasc ; lda drive ;get current drive ora a ;is it A? jz gogo ;if so continue inr a ;else increment sta sfcb ;and store ; gogo: LXI D,SFCB CALL GETFL ;get file list LDA FLCNT ORA A JZ NONE ;no files on current du: MVI A,PRTN STA PCOUNT ; LOOP: CALL CKABRT ;check if any key pressed ;abort if so. LHLD FLPTR ;HL = ptr to next name LXI D,SFCB ;DE = destination addr MVI B,16 ;# bytes to move CALL MOVE SHLD FLPTR ;update file list ptr ; ; Kaypro 10 uses drive C as floppy (sls) ; MVI A,3 ;set drive spec STA SFCB ; ; set for user 0 of the floppy ; mvi c,curusr ;get/set user number mvi e,0 ;USER 0 call bdos ; LXI D,SFCB ;search for file CALL SRCHF ;on drive C. INR A PUSH PSW ; JZ LOOP1 LXI D,MSG6 ;set attribute tag CALL WASC ; LOOP1: MVI A,' ' CALL WACC ;print a space LXI H,SFCB+1 ;point to file name MVI B,8 CALL PMSG ;print file name MVI A,' ' CALL WACC ;print a space MVI B,3 CALL PMSG ;print file type MVI A,' ' CALL WACC ;print a space POP PSW JZ LOOP2 LXI D,MSG7 ;reset attribute tag ;or "*" CALL WASC ; LOOP2: ; LOOP3: LXI H,FLCNT ;decrement filelist count DCR M ;and quit if no files left, JZ DONE ;otherwise continue. LXI H,PCOUNT DCR M ;if this line is full skip the JZ LOOP4 ;spaces and start a new line. LXI D,SPACES CALL WASC ;print " | " JMP LOOP ;and get next file name ; LOOP4: CALL WEOLC ;start a new line MVI A,PRTN STA PCOUNT JMP LOOP ;and get next file name. ; CKABRT: MVI C,GCSFC ;get console status function code CALL BDOS ANA A ;set flags..A=0 if no key pressed RZ CALL RACC ; DONE: CALL WEOLC LXI D,MSG4 CALL WASC CALL RACC MVI C,RESET CALL BDOS ; LXI D,MSG5 CALL WASC ; JMP EXIT ;back to CP/M NONE: LXI D,MSG3 CALL WASC ; ;EXIT ROUTINE RESETS SYSTEM STACK AND RETURNS TO CP/M ; EXIT: LHLD OLDSP SPHL RET ; GETFL: LXI H,FLIST ;FLPTR = FWA OF FILELIST SHLD FLPTR XRA A ;FLCNT = 0 STA FLCNT PUSH D GETFL1: CALL SRCHF ;SEARCH FOR FIRST OCCURRENCE CPI 255 ;JUMP IF NONE FOUND JZ GETFL3 GETFL2: ANI 03H ;DE = DBUF + 32 * (A AND 3) ADD A ADD A ADD A ADD A ADD A MOV L,A MVI H,0 LXI D,DBUF DAD D XCHG LHLD FLPTR ;HL = FILE LIST PTR XCHG MVI B,16 ;B = # OF BYTES TO MOVE CALL MOVE XCHG SHLD FLPTR ;UPDATE FILELIST POINTER LXI H,FLCNT ;INCREMENT FILELIST COUNT INR M POP D PUSH D CALL SRCHN ;SEARCH FOR NEXT OCCURRENCE CPI 255 ;LOOP IF ANOTHER FOUND JNZ GETFL2 GETFL3: POP D LXI H,FLIST ;RESET FILELIST POINTER SHLD FLPTR RET ; MOVE: MOV A,M ;move B bytes from HL to DE ani 7fh ;strip hi bits (if set) INX H STAX D INX D DCR B JNZ MOVE RET ; ;SEARCH FOR FIRST OCCURRENCE OF FILE ;ON ENTRY DE POINTS TO FCB ;RETURNS 0, 1, 2 OR 3 IF FOUND, 255 IF NOT FOUND ; SRCHF: PUSH H PUSH D PUSH B MVI C,SRFFC CALL BDOS POP B POP D POP H RET ;SEARCH FOR NEXT OCCURRENCE OF FILE ; SRCHN: PUSH H PUSH D PUSH B MVI C,SRNFC CALL BDOS POP B POP D POP H RET ; ;READ CONSOLE CHARACTER ;EXIT: CHARACTER IN ACCUM. ; RACC: PUSH H PUSH D PUSH B MOV E,A MVI C,RCCFC CALL BDOS POP B POP D POP H RET ; ;WASC - WRITE BUFFER TO CONSOLE ;ENTRY - DE POINTS TO MESSAGE BUFFER ;MSG MUST END IN '$' ; WASC: PUSH H PUSH D PUSH B MVI C,WCBFC CALL BDOS POP B POP D POP H RET ; ;WEOLC - WRITE END OF LINE (CR,LF) ; WEOLC: MVI A,CR CALL WACC MVI A,LF ; ;WRITE CONSOLE CHARACTER ;ENTRY: CHARACTER IN ACCUM. ; WACC: PUSH H PUSH D PUSH B MOV E,A MVI C,WCCFC CALL BDOS POP B POP D POP H RET ; PMSG: MOV A,M ;prints B characters CALL WACC ;pointed at by HL INX H DCR B JNZ PMSG RET ; cnvrt: mvi e,0ffh ; cnvrt1: inr e dad b jc cnvrt1 mov a,b cma mov b,a mov a,c cma mov c,a inx b dad b mov a,e ora d mov d,a mov a,e ret ; prnd2: lxi b,-10 call cnvrt jz prnd3 call prtdig ; prnd3: mov a,l ; prtdig: adi '0' mov e,a push d push h call output pop h pop d ret ; output: mvi c,wccfc jmp bdos ; ; ; ; MESSAGE AND STORAGE AREA (Kaypro dependant equates) ; MSG0: DB CLR,' ' DB ESC,'B3',' Compare DIRectories - Ver 1.2kp for Kaypro 10 ' DB ESC,'C3',CR,LF,EOS ; MSG1A: DB ESC,'=" ',17H DB ' DIRectory of ',eos ; msg1b: DB ' , files also found on floppy (C0:) are ' DB ESC,'B0','Hilighted' DB ESC,'C0' DB CR,LF,LF,EOS ; MSG2: DB CR,LF DB 'Place diskette to be compared in the floppy drive.',CR,LF,LF DB ' Press: to start',cr,lf DB ' to quit > ',bel,EOS MSG3: DB CR,LF,ESC,'B0' DB ' >> NO files found on this drive/user area. << ' DB ESC,'C0',bel,cr,lf,EOS MSG4: DB cr,lf,'Comparison completed, press : ',bel,EOS ; MSG5: DB VT,17H,EOS ; MSG6: DB ESC,'B0',EOS MSG7: DB ESC,'C0',EOS ; HELPMSG: DB CR,LF DB 'CDIR - Displays the DIR of current user area, files which' DB cr,lf DB ' also exist on the floppy are shown in ' DB ESC,'B0','Reverse' DB ESC,'C0' DB ' video.' DB cr,lf,lf,lf DB 'Usage: CDIR',CR,LF DB ' CDIR *.*',CR,LF DB ' CDIR *.COM',CR,LF DB ' CDIR AB??.??Z',CR,LF DB ' etc.',CR,LF,LF,LF DB 'Note: No matter which user area you are logged into on',cr,lf DB ' the hard drive, user 0 of the floppy will be used',cr,lf DB ' for all comparisons. (Steve Sanders 4/4/86)',cr,lf,lf DB 'Tampa Bay KUG / DataCOM Super Systems (813) 791-1454 modem' DB cr,lf DB EOS ; SPACES: DB ' | ',EOS ; OLDSP: DS 2 ;SYSTEM SP ; DRIVE: DS 1 ;save current drive USER: DS 1 ;save current user# FLCNT: DS 1 ;file list count FLPTR: DS 2 ;file list pointer PCOUNT: DS 1 ;print counter ; STACK: DS 64 FLIST: EQU $ ;file list starts here ; END START