;*************************** AMUS Program Label ******************************
; Filename: PRIO.M68                                        Date: 07/01/89
; Category: UTIL         Hash Code: 642-165-367-422      Version: 1.0(100)
; Initials: PSS/AM       Name: DENNIS W. NEDER
; Company: PROFESSIONAL SOFTWARE SYSTEMS           Telephone #: 8189575930
; Related Files: LIB.UNV  (DON'T FORGET THIS FILE!)
; Min. Op. Sys.: 1.3                           Expertise Level: BEG
; Special: You must LNKLIT this program after assembly
; Description: This program will set all other job's priority level, (except
; the job running PRIO).  Useful on heavily-loaded systems.
;
;*****************************************************************************
;
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
; *     PRIO.M68                                                        *
; *     Program to globally set job's priorities                        *
; *     Copyright (c) 1988 by Dennis W. Neder                           *
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
; *
       SEARCH  SYS
       SEARCH  SYSSYM
       SEARCH  LIB
;
; Version:
;
       VMAJOR=1
       VMINOR=0
       VEDIT=100.

;
; Local equates:
;
       JOB=A0
       TBL=A4
       IMP=A5
;
; Impure storage:
;
       .OFINI
       .OFDEF  PRIO,4
       .OFSIZ  IMPSIZ
;
; Define macros here:
;

DEFINE  DEPACK  ADDR
       IF      NB,ADDR,LEA A1,ADDR
       SUB     #4,SP
       MOV     SP,A2
       UNPACK
       CLRB    @A2
       TTYL    @SP
       ADD     #4,SP
       ENDM

HDR:    PHDR    -1,0,PH$REE!PH$REU!PH$OPR

;
; Begin program here:
;
BEGIN:  NAME    HDR
       CRLF
       CRT     #11.
       TYPECR  Copyright (c) 1988 by Dennis W. Neder
       CRT     #12.
       GETIMP  IMPSIZ,IMP              ; Get our temporary storage
       JOBIDX  JOB                     ; Who are we?
       BYP
       LIN                             ; Any priority given?
       BNE     20$
10$:    CRLF
       TYPESP  <Enter desired priority:>
       KBD     EXIT$
20$:    NUM                             ; Insure numeric @A2
       BEQ     30$                     ; Yes - continue
       TTYL    NUMPRI
       CRLF
       BR      10$                     ; Try again
30$:    GTDEC                           ; Get the value
       CMP     D1,#1                   ; Let's begin to check the range...
       BLO     40$
       CMP     D1,#254.
       BHI     40$
       BR      SETPRI
40$:    TTYL    BADPRI
       CRLF
       BR      10$

SETPRI: MOV     D1,PRIO(IMP)            ; Save our priority
       CRLF
       TYPECR  <Setting priorities on:>
       CRLF
       MOV     JOBTBL,TBL              ; Index job table
10$:    MOV     (TBL)+,D0               ; Get next job
       BEQ     10$                     ; Branch if de-allocated
       BMI     EXIT$                   ; Branch if end of job table
       MOV     D0,A1                   ; A1 points to current job
       CMP     A1,JOB                  ; Is this me?
       BEQ     10$                     ; Yes - don't change my priority
       MOV     A1,A3                   ; Save for later
       TAB                             ; Output a tab character
       DEPACK  JOBNAM(A1)              ; print job name
       DEPACK
       MOV     A3,A1                   ; Restore A1
       CRT     #11.
       TYPESP  <  Previous priority:>
       CRT     #12.
       MOV     JOBRNQ+20(A1),D1        ; Get previous priority
       DCVT    0,OT$TRM
       CRLF
       MOV     A3,A1
       MOV     PRIO(IMP),JOBRNQ+20(A1) ; Load new job priority
       BR      10$                     ; continue

EXIT$:  EXIT

NUMPRI: ASCIZ   /?Priority must be numeric/

BADPRI: ASCIZ   /?Priority must be in the range 1 - 256/

       END