OBJNAM DELMEM.LIT ; Created 14-May-87, edited 14-May-87
; by Irv Bromberg, Medic/OS Consultants, Toronto, Canada
; Immediately deletes any specified memory module from MEM: provided
; it does not have FGD or LOK bits set.
RADIX 10
VMAJOR=1
VMINOR=0
VEDIT=1

SEARCH SYS
SEARCH SYSSYM

if eq,1
Syntax:  DELMEM  name.ext

The default extension is ".DAT".  Take care not to delete a module that
is below something else that must not be moved (such as an executing
program).

DELMEM.LIT is re-entrant and re-useable.

endc

JCB=A0
Buffer=A2
Name=A3
Module=A5

Char=D1

       PHDR    -1,0,PH$REE!PH$REU

       MOV     JOBCUR,JCB              ; use JOBRBK as work area
       LEA     Name,JOBRBK(JCB)
       CLR     @Name                   ; pre-clear filename in case
       CLR     4(Name)                 ; of invalid entry
       FILNAM  @Name,DAT

Search: SRCH    @Name,Module,F.USR      ; module in MEM:?
       BEQ     ChkPRM
       TYPE    <?Cannot find>
ShowName:TYPE   < MEM:>
       PRNAM   @Name
       CRLF
       EXIT

ChkPRM: MOVW    -8(Module),D7           ; check for FGD and LOK
       ANDW    #FGD!LOK,D7
       BEQ     DoIt
       TYPE    <?Cannot delete permanent module>
       BR      ShowName

DoIt:   PUSH
       PUSH    Module
       DELMEM  @SP
Done:   EXIT

       END