;************************************
;*	JOBLST.M68
;*
;*      Scans the system and prints
;*      every defined job to the screen.
;*
;*      Usage: JOBLST
;*
;*	by Dave Heyliger - AMUS Staff	
;************************************

	OBJNAM	JOBLST.LIT		;Define the final product

	SEARCH SYS			;Grab all MACRO definitions
	SEARCH SYSSYM
	SEARCH TRM

;--- The following will define a 'version number' that will be displayed
;    when you do a DIR/V JOBLST.LIT. These numbers are 'made-up' by the
;    programmer, and can be changed when the code is changed.
;
	VMAJOR=1.			;Major version number of the program
	VMINOR=0.			;Minor version number of the program
	VEDIT=100.			;the edit number of the program

;--- This small portion of the code reserves a little memory space in YOUR
;    memory partition for a variable I called "BUFFER".
;
	.OFINI				;OFfset INItialization:
	.OFDEF	BUFFER,7.		;OFfset DEFinition - "BUFFER"
	.OFSIZ	IMPSIZ			;IMPSIZ is the final size of bytes (7)

;--- Start the program with a header, and also get the size of our memory
;    buffer - the 7 bytes where byte "0" is the 1st byte of 7 in "BUFFER".
;
	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

;--- Now get the ADDRESS of the start of the JOB table and plop it into A0
;
GETTBL:	MOV	JOBTBL,A0		;Get base of JOB TABLE into A0

;--- The following loop will 1) get all names from the JOB TABLE (in RAD50)
;   			     2) unpack the RAD50 charaters, and
;			     3) print the names to the screen
;
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"
	LEA	A1,JOBNAM(A4)		;else ^ A1 to the start of a JOB name
	LEA	A2,BUFFER(A5)		;and ^ A2 to byte "0" of "BUFFER"
	UNPACK				;Find the ASCII letters in JOBNAM
	UNPACK				;  ...for up to 6 digits
	CLRB	@A2			;Place a "null" after the characters
 	LEA	A2,BUFFER(A5)		;Repoint A2 to byte "0" of "BUFFER"
	TTYL	@A2			;Print out all chars until a null
	CRLF				;Carriage return & line feed
	JMP	LOOP			;Time for the next name in the table

;--- Finally, let the user know you are through
;
EXIT:	TYPE <End of Job listing for this system>    
	CRLF
	EXIT				;return to AMOS

	END