;*; Updated on 13-Jan-92 at 11:57 AM by Michele Tonti; edit time: 0:00:05
;*****************************************
;*      JOBRUN.M68
;*
;*      Scans the system and prints
;*      every defined job to the screen
;*      AND the program they are running.
;*
;*      Usage: JOBRUN
;*
;*      by Dave Heyliger - AMUS Staff
;*****************************************

       OBJNAM  JOBRUN.LIT              ;Define the final product

       SEARCH SYS                      ;Grab all MACRO definitions
       SEARCH SYSSYM
       SEARCH TRM

       VMAJOR=1.                       ;Major version number of the program
       VMINOR=0.                       ;Minor version number of the program
       VEDIT=100.                      ;the edit number of the program

       .OFINI                          ;OFfset INItialization:
       .OFDEF  BUFFER,7.               ;OFfset DEFinition - "BUFFER"
       .OFSIZ  IMPSIZ                  ;IMPSIZ is the final size of bytes (7)

DEFINE  TYPEIT  V,B
;+---
;| TYPEIT will process a JCB variable that is two words packed RAD50 data
;|        and type this variable to the screen in ascii format.
;| where
;|        V = variable to be UNPACKED
;|        B = BUFFER area to place unpacked characters
;+--------------------------------------------------------------------------
       LEA     A1,V(A4)                ;A1 points to variable to be unpacked
       LEA     A2,B(A5)                ;and ^ A2 to byte "0" of "BUFFER"
       UNPACK                          ;get the letters unpacked
       UNPACK                          ;  ...for up to full letters
       CLRB    @A2                     ;Place a "null" after the characters
       LEA     A2,B(A5)                ;Repoint A2 to byte "0" of "BUFFER"
       TTYL    @A2                     ;Print out all chars until a null
ENDM                                    ;END of the Macro definition

       PHDR    -1,0,PH$REE!PH$REU      ;Program is Re-entrant & Re-useable
       GETIMP  IMPSIZ,A5               ;Reg. A5 now ^'s to byte "0" of BUFFER
       MOV     JOBTBL,A0               ;Get base of JOB TABLE into A0
       TYPECR  < Job     Program>      ;type out column headings
       TYPECR  <-------+-------->      ;and a fancy underline

LOOP:   MOV     (A0)+,A4                ;and let A4 point to each JBC
       MOV     A4,D0                   ;this will set the flags 2 B checked
       BMI     EXIT                    ;end of the JOB TABLE on a "-1"
       BEQ     LOOP                    ;goto the top on a "0"
       TYPEIT  JOBNAM,BUFFER           ;type out the JOB NAME
       TYPE    <   >                   ;type some spaces
       TYPEIT  JOBPRG,BUFFER           ;type out the PROGRAM NAME
       CRLF                            ;Carriage return & line feed
       JMP     LOOP                    ;Time for the next JOB in the table

EXIT:   EXIT                            ;return to AMOS

       END