; ; BAK.ASM ; -- Erases all files with the extension .BAK ; ; USAGE: ; ; BAK {d:} ; ; Erases all .BAK files on the specified drive. If the drive ; is not given then the currently logged drive is assumed. ; ; Based on the public domain BK.MAC, written to be assembled with ; M80. Modified May 11, 1987, by Gene Pizzetta, to allow a drive ; parameter in the command line and to assemble with MAC. ; WStart equ 00h Bdos equ 05h CpmFcb equ 5Ch PrtStr equ 09h Erase equ 13h CurDisk equ 19h NoFile equ 0FFh CR equ 0Dh LF equ 0Ah ; MACLIB Z80 org 100h ; jmp MAIN db ' BAK 1.1 ' ; ; check for drive specification ; MAIN: lda CpmFcb ; check default FCB cpi 0 ; is it the default drive? cz DEFAULT ; if so, find out what it is sta DISK ; put the drive spec into FCB adi 64 ; make it printable sta MSG1a ; stuff it into messages sta MSG2a ; ; set up CP/M erase call and execute it ; mvi c,Erase lxi d,FCB ; point at FCB call Bdos ; do it ; mvi c,PrtStr ; print message lxi d,MSG2 ; no files message cpi NoFile ; or JRZ PRT lxi d,MSG1 ; normal message PRT: call Bdos ; jmp WStart ; return to BDOS ; DEFAULT: mvi c,CurDisk ; get current drive call Bdos adi 1 ; make it acceptable to FCB ret ; FCB: DISK: db 0 ; target disk FNAME: db '????????' ; wildcard filename EXT: db 'BAK' ; .BAK filetype ; ; blank out remainder of the FCB ; db 0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0 ; MSG1: db '.BAK file(s) erased on drive ' MSG1a: db 0,':',CR,LF,'$' MSG2: db 'No .BAK files found on drive ' MSG2a: db 0,':',CR,LF,'$' ; end