; TDIR.AZM vers 1.0 modified by R.Gaspari 12-04-87 ; Assemble with Z80MR. ; ; Comments: Produces a non-alphabetized listing of matching filenames ; and their Z80DOS time stamps on console. ; ; Usage: TDIR ? display help ; TDIR [d:][afn] display timestamp of specific file tab equ 09h cr equ 0dh lf equ 0ah fcb1 equ 05ch dskbuf equ 80h bdos equ 5 sfirst equ 17 snext equ 18 getstp equ 54 ; Z80DOS call to get the time stamp vers equ 10 org 0100h ; ; Test for help command ; ld a,(fcb1+1) ; check for help request cp '?' ; help command? jr nz,nohelp ; no call print ; display help and exit db 'TDIR Version ' db vers/10+'0','.',(vers.mod.10)+'0' db ' for Z80DOS',cr,lf,lf db ' Display time stamps of any file. ',cr,lf db ' Syntax:',tab,' TDIR [d:][afn] ',cr,lf,lf,0 ret ; exit to cpm ccp ; ; Begin output ; nohelp: ld a,(fcb1+1) cp ' ' ; Filespec given? jr nz,test ld hl,fcb1+1 ; No, match all files ld a,'?' ld b,11 fill: ; Fill with '?' ld (hl),a inc hl djnz fill ; ; Search for match ; test: ld de,fcb1 ld c,sfirst call bdos cp 0ffh ; No matches jp nz,found call print db 'TDIR no matching files.',cr,lf,0 ret ; ; Matches found - print header: ; found: call print db tab,tab,' ---Updated---- ---Created---- ' db cr,lf,0 call process ; Display name and stamp of first match ; ; Search for next match ; next: call condin ; Test pause call nz,cin ; Get input to restart ld de,fcb1 ld c,snext call bdos cp 0ffh ; No more matches jp z,0 call process ; Display name and stamp of next match jr next ; ; Process - Get date/time stamp, display filename and stamp ; process: push af ; save dir. return code from search ; ; Store time stamp ; ld c,getstp ; Z80DOS call call bdos ; HL --> stamp ld bc,10 ; copy 10 byte stamp ld de,cdate ldir ; to cdate, udate ; ; Print file name and stamp ; pop af ; Get return code (A=0,1,2,3 gives add a,a ; relative starting position) add a,a add a,a ; Multiply by 32 (32bytes per fname) add a,a add a,a add a,81h ; Point to matching filename in DMA ld e,a ; (DMA starts at 0080h) ld d,0 ; put start addr in de call pfn1 ; SYSLIB print file name pointed to by DE call ptab call printstp ; Display stamp call crlf ret ; ; PrintStp - Display file's time stamp from buffers ; PrintStp: ld hl,udate call cdsp call space ld hl,cdate call cdsp ret ptab: ; Print a tab on console ld a,tab call cout ret space: ; Print a space on console ld a,' ' call cout ld a,' ' call cout ret ; ************************************* ; SUBROUTINES ADDED cin: push hl ; character input using bdos ld c,1 call 5 pop hl ret cout: push bc push de push hl ; char output using bdos ld c,2 ld e,a call 5 pop hl pop de pop bc ret condin: push hl ; char status check ld c,0bh call 5 pop hl ret ; a=FF means a char is waiting crlf: push hl ld c,9 ld de,crmsg call 5 pop hl ret crmsg: db 0dh,0ah,'$' print: ex (sp),hl ; print the string following prnt2: ld a,(hl) ; the call. Terminate by 0. or a jr z,prnt3 call cout inc hl jr prnt2 prnt3: ex (sp),hl ret pfn1: ld b,8 ; print the filename in FCB buffer pfn11: ld a,(de) call cout inc de dec b jr nz,pfn11 call dot ld b,3 pfn12: ld a,(de) call cout inc de dec b jr nz,pfn12 ret dot: push hl ; print a dot push de ld e,'.' ld c,2 call 5 pop de pop hl ret ; **************************************** ; CDSP - CLOCK DISPLAY ; **************************************** CDSP: LD B,5 ; convert 5 bcd bytes to ascii LD DE,CDABUF+1 ; point to start of ascii data buffer CDS2: LD A,(HL) ; get the bcd data byte CALL CDASC ; convert it & store at DE & DE+1 INC HL ; point to next bcd data INC DE ; point to next ascii buffer loc DEC B ; countdown 5 bcd bytes JR NZ,CDS2 ; LD HL,CDABUF ; point HL to start of cdabuf LD B,16 ; count 16 bytes to send out CDS4: PUSH BC PUSH HL LD E,(HL) ; get the byte to send to console LD C,2 ; display using bdos CALL 5 POP HL POP BC INC HL ; point to next loc DEC B ; continue for all 16 bytes JR NZ,CDS4 RET ; normal retn from CDSP CDABUF: DB ' ' DB 0,0,'/' ; month ascii DB 0,0,'/' ; day ascii DB 0,0,' ' ; year ascii DB 0,0,':' ; hour ascii DB 0,0,' ' ; min ascii CDASC: LD C,A ; save incoming byte for later AND 0F0H ; mask upper nibble RLCA ; shift right 4 times RLCA ; (or left 4 times) RLCA ; RLCA ; CALL CDAS2 ; convert and store LD A,C ; get byte back AND 0FH ; mask lower nibble CDAS2: OR 30H ; convert to ascii LD (DE),A ; store it INC DE ; move to next loc for next nibble RET ; retn CDAS2 & retn CDASC ; ----------------------- ; Data Area ; ----------------------- cdate: ds 3 ; create date ctime: ds 2 ; create time udate: ds 3 ; update date utime: ds 2 ; update time end ; END of TDIR