;*************************** AMUS Program Label ******************************
; Filename: ULKMEM.M68                                      Date: 05/18/89
; Category: UTIL         Hash Code: 527-435-504-115      Version: 1.0
; Initials: IRW/AM       Name: IRWIN GOLDSTEIN
; Company: LONDON HOUSE INC.                       Telephone #:
; Related Files: LOKMEM.M68
; Min. Op. Sys.:                               Expertise Level: BEG
; Special:
; Description: Unlocks memory module which was originally locked by the
; LOKMEM utility.
;
;*****************************************************************************
;       Written on:     11/22/85

;       Usage:
;       =====
;               .ULKMEM module

;       Where "module" is the name of the memory module to be unlocked.  The
;       module WILL stay resident, however, until you DEL or ERASE it.
;       ULKMEM exists mainly to allow you to remove memory modules locked
;       into your partition by LOKMEM without logging off (and thus
;       destroying ALL memory modules in your partition).

       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
       ANDW    #^C<20>,-10(A1)         ; all is well - clear the lock bit
       TYPECR  <Module unlocked>
       BR      DONE

;       Module is in system memory - can't unlock 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