perm filename PINK.1[HAK,ROB]1 blob sn#429123 filedate 1979-04-01 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002		TITLE PINK
C00004 00003	FSInit:	 Initialize the Free Storage List
C00006 00004	 PROCEDURE AllWho(Array)
C00007 00005	 executable code
C00008 ENDMK
C⊗;
	TITLE PINK

; ac definitions
AC1 ← 1;
AC2 ← 2;
AC3 ← 3;
AC4 ← 4;
P ← 17;

; data storage

pdlen ←← 20;
pdl:	BLOCK pdlen
pdlptr:	IOWD pdlen,pdl


MinJob←←=1			; Lowest valid job #
MaxJob←←=63			; Highest valid job #
WhoLen←←=22			; Length of a WhoLine as returned by a WHO UUO
Next←←0			; Link word constant

; The format of a WhoLine record is:
; |link word|22 words of Ascii text as returned by a WHO UUO....|

RecSiz←←WhoLen+1		; Length (in words) of a WhoLine record
MaxRec←←MaxJob-MinJob+5		; Maximum number of WhoLine records we will need

RecBuf:	BLOCK RecSiz*MaxRec	; Storage for WhoLine records
FSHead:	BLOCK 1			; Pointer to head of Free Storage list
Fantom:	BLOCK 1			; Pointer to head of Fantom list
Person:	BLOCK 1			; Pointer to head of Person list

FSInit:	; Initialize the Free Storage List
;
; AC1 = this record
; AC2 = next record
;
	PUSH	P,AC1		;
	PUSH	P,AC2		;
	MOVEI	AC2,FSBuff	;
	MOVEI	AC1,FSList	;
loop:				;
	MOVEM	AC2,Link(AC1)	; store in NEXT(this)
	MOVE	AC1,AC2		; this ← next
	ADDI	AC2,RecSiz	; generate pointer to next
	CAIGE	AC2,BufEnd	; 
	JRST	loop		;
	POP	P,AC2		;
	POP	P,AC1		;
	POPJ	P,
;
GetRec:	; Get a (fixed length) record from Free Storage
;
; Outputs:
;   AC1 ← pointer to record
;
	MOVEI	AC1,FSList
	MOVE	AC2,Link(AC1)
	MOVE	AC3,Link(AC2)
	MOVEM	AC3,AC1
	
; PROCEDURE FaInit	Initialize the Fantom list
; PROCEDURE PeInit	Initialize the Person list

; PROCEDURE AllWho(Array)

  COMMENT ⊗ This procedure will fill up the specified array with the
    WhoLines of all jobs.  'Array' is assumed to be an array of records,
    each record WhoLen words long. ⊗

ArrLoc←←-1;
PDLeng←←2;

AllWho:			; Fill an array with WhoLine information for all jobs
	MOVE a,ArrLoc(p)	; fetch starting address of array
	HRLI a,MinJob		; set first job # to look at
	MOVEI b,MaxJob		; set up counter
loop:				; 
	WHO a,			;
	ADD a,[1,,WhoLen]	; Next job,,Next Record
	SOJG b,loop		; loop until all jobs looked at
	ADJSP p,-PDLeng		; Roll back the SP
	JRST @PDLeng(p)		; and return

; executable code

start:
	RESET
	MOVE p,pdlptr
	PUSH p,[WhoBuf]		; Set up pointer into WhoLine buffer
	PUSHJ p,AllWho		; We will count down through the jobs
	EXIT

	END start