;*************************** AMUS Program Label ******************************
; Filename: LOKMEM.M68                                      Date: 05/18/89
; Category: UTIL         Hash Code: 072-040-154-222      Version: 1.0
; Initials: IRW/AM       Name: IRWIN GOLDSTEIN
; Company: LONDON HOUSE INC.                       Telephone #:
; Related Files: ULKMEM.M68
; Min. Op. Sys.:                               Expertise Level: BEG
; Special:
; Description: Utility to lock a memory module (so that DEL or ERASE MEM:
; cannot erase module). Use ULKMEM to unlock memory module.
;
;*****************************************************************************
;       Written on:     11/22/85
;
;       Usage:
;       =====
;               .LOKMEM module

;       Where "module" is the name of the module to be locked.  The module
;       must already be in user memory or an error message will be displayed.
;       The module specified will be locked so that it cannot be DELed or
;       ERASEd from memory.  In fact, logging off is the only way to get
;       rid of it! (Other than using ULKMEM, then DEL or ERASE.)  This is
;       especillay useful for keeping function key definitions (.PFK files)
;       from getting deleted by commands that like to clean up memory.

;       NOTES:
;       =====
;       Use ULKMEM to get unlock a memory module you don't want anymore.

       SEARCH  SYS                     ; system macros
       SEARCH  SYSSYM                  ; system symbols
       SEARCH  TRM                     ; terminal symbols

;       Workspace:

       ASECT
       .=0
MODNAM: BLKW    3                       ; module name packed RAD50
MEMSIZ:
       PSECT
       .=0

;       Program header:

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

;       Program begins:

       GETIMP  MEMSIZ,A0               ; get us some workspace
       MOV     A0,A1                   ; index the workspace
       FILNAM  @A1,LIT                 ; pack the module name RAD50 into workspace
       BEQ     FILERR                  ; abort on filespec error
       SRCH    @A0,A1                  ; look for the module
       BNE     NOFIND                  ; abort if not found
       USRBAS  A0                      ; index the base of our memory
       CMP     A1,A0                   ; is module lower than our memory?
       JLO     INSYS                   ;   yes - it must be in system memory
       ORW     #20,-10(A1)             ; all is well - set the lock bit
       TYPECR  <Module locked>
       BR      DONE

;       Module is in system memory - no need to lock it:

INSYS:  TYPECR  <?Module in system memory>
       BR      DONE

;       Module is no where to be found:

NOFIND: TYPECR  <?Memory module not found>
       BR      DONE

;       An illegal file name was given:

FILERR: TYPECR  <?Illeagl module name>

DONE:   EXIT