home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol097 / purge.mac < prev    next >
Encoding:
Text File  |  1984-04-29  |  5.6 KB  |  190 lines

  1. title    PURGE, a utility for Pascal/z to delete extraneous files
  2. ; PURGE
  3. ; A utility to erase unnecessary files associtated with test compilations
  4. ; May be conditioned to operate on the Heath/Zenith-19(89/90) terminal.
  5. ;
  6. ; John S. Wilson
  7. ; Synapse Associates, Inc.,
  8. ; PO Box 410, Solomons, Maryland 20688
  9. ; (301) 326-4751
  10. ;
  11. ; Source code to be assembled with Macro-80 (or some other z80 assembler)
  12. ; There are NO macros in this source
  13. .z80            ;assemble z80 code
  14.     aseg            ;this is a main program 
  15. ; Set this constant for use with the Heath/Zenith equipment
  16. seth19    equ    1        ;1=use on Heath/Zenith term. 0=other terminals
  17. ; Set this constant to get a warm boot on exit
  18. setwmb    equ    1        ;1=do a warm boot on exit, 0=don't do one.
  19.     org    0100h
  20. ;
  21. ; Determine if the file type is SRC 
  22. ; set up the pointers
  23.     ld    b,3        ;the number of bytes in the file extension
  24.     ld    hl,ftsrc    ;address of data string 'SRC'
  25.     ld    de,flext    ;extension location in the fcb
  26. cmpsrc:    ld    a,(de)
  27.     sub    (hl)        ;destructive compare
  28.     jp    nz,notsrc    ;not equal, stop testing 
  29.     inc    de        ;bump counters
  30.     inc    hl
  31.     djnz    cmpsrc        ;same so far, keep on looking
  32.     ld    a,delflg    ;put value of delete flag in a
  33.     ld    (delsrc),a    ;store in delsrc (which was preset to 1)
  34. ;
  35. notsrc:    ift    seth19        ;is the term a H/Z?
  36.     call    wipe        ;if yes wipe the screen 
  37.     call    rvon        ;and turn on reverse video
  38.     endif    
  39. ;
  40.     ld    de,signon    ;load the address of the sign on message
  41.     call     dplmsg        ;dplmsg writes messages to the console
  42.     ift    seth19        ;announce terminal type on sign-on line
  43.     call    hzterm
  44.     endif
  45.     ld    de,crlfm
  46.     call    dplmsg
  47. ;
  48. ; CP/M puts the file name in the command line in the file control block
  49. ; check to see if it is exists.
  50.     call    probe    ;
  51.     cp     255    ;a contains 255 after an error condition
  52.     jp    nz,chkfil    ;skip if open is ok
  53. ;
  54. ; File not found on named or default disk, cease processing
  55.     ld     de,errmsg    ;load error message
  56.     call    dplmsg        ;display it
  57.     jp    klenup        ;bail out
  58. ; The file was found in the directory, delete selected extensions with the
  59. ; same root file name.
  60. chkfil:    ld    de,opmsg    ;load the file found message
  61.     call    dplmsg        ;display it on the console
  62.     ld    a,(delsrc)
  63.     cp    delflg        ;
  64.     jp    nz,ldext0    ;not marked for save, no message
  65.     ld    de,srcmsg    ;report results of examination
  66.     call    dplmsg    
  67. ;
  68. ldext0:    ld    hl,fthex    ;load the address of the first extension type
  69.                 ;to be deleted
  70. ; Delete loads the extension type into the correct location of the file
  71. ; control block and then references the CP/M file delete function
  72.     call    delete        
  73.     ld    hl,ftbak    ;next file extension name address
  74.     call    delete        
  75. ; run time test for the deletion of <filename>.SRC 
  76.     ld    a,(delsrc)    ;1 = delete, 0 = not delete this file type
  77.     cp    delflg        ;compare with the delete flag
  78.     jp    z,dotyp
  79.     ld    hl,ftsrc
  80.     call    delete
  81. dotyp:    ld    hl,fttyp
  82.     call     delete
  83.     ld    hl,ftrel
  84.     call    delete
  85.     ld    hl,ftsym
  86.     call    delete
  87.     ld    hl,ftcrf
  88.     call    delete
  89.     ld    hl,ftprn
  90.     call    delete
  91.     ld    hl,ftlst
  92.     call    delete
  93. klenup:    call    rvoff        ;don't forget to turn out the lights
  94.     ift    setwmb
  95.     jp    boot        ;do a warm boot - ^C to force cache Bios
  96.     else            ;to rewrite the track buffer upon exit
  97.     ret            ;assuming that the write track buffer on warm
  98.     endif            ;boot option is turned on.  Alternatively, one
  99.                 ;may simply code a return - ret, providing an 
  100.                 ;opportunity to snatch the disk out and prevent
  101.                 ;the action of the program from being written
  102.                 ;to disk.
  103. ;
  104. probe:    ld    de,fcb    ;file data (including name) in the file control block
  105.     ld    c,openf    ;the open file function for CP/M
  106.     call     bdos
  107. ; Don't really care about the results of the open at this point so don't
  108. ; save the results of the condition word in r a
  109.     ld     de,fcb    ;reload the fcb address into de
  110. ; If the file was existed, it was opened, now close it
  111. ; If it didn't exist, attempting to close it will produce the error code
  112.     ld    c,closef    ; just to keep it safe!!
  113.     call    bdos
  114.     ret
  115. ;
  116. ;
  117. ; Delete loads the address of the fcb, the number of byte in the file extension
  118. ; and does a block load to the part of the fcb where the extension is stored.
  119. ; It then calls CP/M to delete the file named in the fcb
  120. delete:    ld    de,flext    ;the address of the file extension in the fcb
  121.     ld    bc,03h        ;the number of bytes to move
  122.     ldir            ;a block move
  123.     ld    de,fcb        ;the address of the file control block
  124.     ld    c,killf        ;the file delete function code
  125.     call    bdos        ;call CP/M
  126.     ret
  127. ; display any image whose initial address in in rr de
  128. dplmsg:    ld    c,printf    ;print buffer function
  129.     call    bdos
  130.     ret
  131. ;
  132. wipe:    ld    de,wipem
  133.     call    dplmsg
  134.     ret
  135. ;
  136. rvon:    ld    de,rvonm    ;reverse video on for heath/zenith-19
  137.     call    dplmsg
  138.     ret
  139. ;
  140. rvoff:    ld    de,rvoffm    ;reverse video off for heath/zenith-19
  141.     call    dplmsg
  142.     ret
  143. ;
  144. hzterm:    ld    de,hztmsg    ;announce Heath/Zenith gear
  145.     call    dplmsg    
  146.     ret
  147. ;
  148. ;    message area
  149. signon:    db    'File Purge Vers 2.2, 17 July 1982$'
  150. errmsg:    db    bel,bel,bel,lf,lf,'file NOT found in directory$'
  151. opmsg:    db    'file found in directory$'
  152. wipem:    db    esc,'E$'
  153. rvonm:    db    esc,'p$'
  154. rvoffm:    db    esc,'q$'
  155. hztmsg:    db    ' - Heath-19 Terminal$'
  156. srcmsg:    db    cr,lf,'File type ''SRC'' will NOT be deleted$',cr,lf
  157. crlfm:    db    cr,lf,'$'
  158. ;
  159. ;Declarations of file extensions types to be deleted
  160. fthex:    db    'HEX'
  161. ftbak:    db    'BAK'
  162. ftsrc:    db    'SRC'
  163. fttyp:    db    'TYP'
  164. ftrel:    db    'REL'
  165. ftsym:    db    'SYM'
  166. ftcrf:    db    'CRF'
  167. ftprn:    db    'PRN'
  168. ftlst:    db    'LST'
  169. delflg    equ    0        ;Delete flag reference value 
  170. delsrc:    db    1        ;SRC delete variable
  171. ;
  172. esc    equ    01bh
  173. boot    equ    0000h
  174. bdos    equ    0005h    
  175. printf    equ    09h    ;buffer print entry
  176. openf    equ    0fh    ;open file function
  177. closef    equ    10h    ;close file function
  178. killf    equ    13h    ;delete file function
  179. fcb    equ    5ch    ;file control block address
  180. cr    equ    0dh    ;carriage return
  181. lf    equ    0ah    ;line feed
  182. bel    equ    07h    ;bell
  183. ; location in the file control block
  184. flext    equ    fcb+9    ;file type (3 characters)
  185. ;
  186. ; stack area
  187. ;    ds    64    ;The label is at the high end (top) of the stack 
  188. ;locstk:            ;because the stack pointer is decremented in use.
  189.     end    0100h
  190.