Google
 

Trailing-Edge - PDP-10 Archives - BB-R598A-RM_1983 - swskit-v3/listings/vnp36/stgm.list
There are no other files named stgm.list in the archive.
Cnet-10 Compatibility
!
!	, : VERSION
! 01	-
!--

!<BLF/PAGE>
								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   1
								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (1)

;	  0001	!<REL4A.TKB-VNP>STGM.BLI.3,  3-Dec-79 15:02:34, Edit by SROBINSON
;	  0002	MODULE STGM (					! STORAGE MANAGER
;	  0003			IDENT = 'X2.0'
;	  0004			) =
;	  0005	BEGIN
;	  0006	!
;	  0007	!
;	  0008	!
;	  0009	!                    COPYRIGHT (c) 1980, 1981, 1982
;	  0010	!                    DIGITAL EQUIPMENT CORPORATION
;	  0011	!                        Maynard, Massachusetts
;	  0012	!
;	  0013	!     This software is furnished under a license and may  be  used
;	  0014	!     and copied only in accordance with the terms of such license
;	  0015	!     and with the inclusion of the above copyright notice.   This
;	  0016	!     software  or any other copies thereof may not be provided or
;	  0017	!     otherwise made available to any other person.  No  title  to
;	  0018	!     and ownership of the software is hereby transferred.
;	  0019	!
;	  0020	!     The information  in  this  software  is  subject  to  change
;	  0021	!     without  notice  and should not be construed as a commitment
;	  0022	!     by DIGITAL EQUIPMENT CORPORATION.
;	  0023	!
;	  0024	!     DIGITAL assumes no responsibility for the use or reliability
;	  0025	!     of  its  software  on  equipment  which  is  not supplied by
;	  0026	!     DIGITAL.
;	  0027	!
;	  0028	
;	  0029	!++
;	  0030	! FACILITY: TKB-20 AND VNP-20
;	  0031	!
;	  0032	! ABSTRACT:
;	  0033	!
;	  0034	!
;	  0035	! THIS MODULE PROVIDES THREE STORAGE MANAGEMENT SUBROUTINES.
;	  0036	!
;	  0037	!  GETSTG(AMOUNT) GETS 'AMOUNT' OF STORAGE, RETURNING ITS
;	  0038	!   ADDRESS AS ITS VALUE.  RETURNING A 0 INDICATES THAT NO
;	  0039	!   STORAGE IS AVAILABLE.
;	  0040	!
;	  0041	!  FRESTG(ADDRESS,AMOUNT) FREES 'AMOUNT' OF STORAGE STARTING
;	  0042	!   AT 'ADDRESS'.  IT RETURNS NO VALUE.
;	  0043	!
;	  0044	!  INISTG(AMOUNT) INITIALIZED STORAGE MANAGEMENT.  SUBSEQUENTLY,
;	  0045	!   AT LEAST 'AMOUNT' OF STORAGE WILL BE AVAILABLE THROUGH GETSTG.
;	  0046	!   RETURNING A 0 INDICATES THAT INITIALIZATION FAILED, 1 THAT IT
;	  0047	!   SUCCEEDED.
;	  0048	!
;	  0049	!
;	  0050	!
;	  0051	! ENVIRONMENT: TOPS-20 USER MODE
;	  0052	!
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   2
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (1)

;	  0053	! AUTHOR: J. SAUTER, CREATION DATE: 14-DEC-77
;	  0054	!
;	  0055	! MODIFIED BY:
;	  0056	!
;	  0057	!	Scott G. Robinson, 3-DEC-79 : Version X2.0
;	  0058	!	- Ensure DECnet-10 Compatibility
;	  0059	!
;	  0060	!	, : VERSION
;	  0061	! 01	-
;	  0062	!--
;	  0063	
;	  0064	!<BLF/PAGE>
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   3
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (2)

;	  0065	!
;	  0066	! TABLE OF CONTENTS:
;	  0067	!
;	  0068	
;	  0069	FORWARD ROUTINE
;	  0070	    INISTG : NOVALUE,				!INITIALIZE STORAGE MANAGER
;	  0071	    GETSTG,					!GET STORAGE
;	  0072	    COLLECT_STORAGE : NOVALUE,			!COMBINE ADJACENT STORAGE BLOCKS
;	  0073	    FRESTG : NOVALUE,				!FREE STORAGE
;	  0074	    GETBLK,					!GET A BLOCK
;	  0075	    FREBLK : NOVALUE;				!FREE A BLOCK
;	  0076	
;	  0077	!
;	  0078	! INCLUDE FILES:
;	  0079	!
;	  0080	!	NONE
;	  0081	!
;	  0082	! MACROS:
;	  0083	!
;	  0084	!	NONE
;	  0085	!
;	  0086	! EQUATED SYMBOLS:
;	  0087	!
;	  0088	
;	  0089	LITERAL
;	  0090	    DEBUG = 0;
;	  0091	
;	  0092	!
;	  0093	! DEFINE A STRUCTURE WHICH PROVIDES ACCESS TO ADDRESSES.
;	  0094	!  IF %BPUNIT = %BPADDR, THIS IS THE SAME AS STRUCTURE "VECTOR".
;	  0095	!
;	  0096	
;	  0097	STRUCTURE
;	  0098	    ADDRESSES [INDEX; VLENGTH] =
;	  0099		[((VLENGTH*%BPADDR) + (%BPUNIT - 1))/%BPUNIT]
;	  0100		(ADDRESSES + ((INDEX*%BPADDR)/%BPUNIT))<(INDEX*%BPADDR) MOD %BPUNIT, %BPADDR>;
;	  0101	
;	  0102	!
;	  0103	! DEFINE THE OFFSETS IN THE HEADER FOR A STORAGE BLOCK ON THE
;	  0104	!  FREE CHAIN.
;	  0105	!
;	  0106	
;	  0107	LITERAL
;	  0108	    FSTG_SIZE = 0,				!SIZE OF THIS BLOCK
;	  0109	    FSTG_NEXT = 1,				!POINTER TO NEXT BLOCK, OR 0 IF NONE.
;	  0110	    FSTG_PREV = 2,				!POINTER TO PREV BLOCK, OR 0 IF THIS IS FIRST.
;	  0111	    FSTG_HDRL = 3;				!LENGTH OF A FREE STORAGE HEADER
;	  0112	
;	  0113	!
;	  0114	! OWN STORAGE:
;	  0115	!
;	  0116	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   4
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (2)

;	  0117	OWN
;	  0118	    INITIALIZED : INITIAL (0),
;	  0119	    FSTG_ROOT : ADDRESSES [FSTG_HDRL],
;	  0120	    COUNTS : VECTOR [513];
;	  0121	
;	  0122	!
;	  0123	! EXTERNAL REFERENCES:
;	  0124	!
;	  0125	
;	  0126	EXTERNAL ROUTINE
;	  0127	    ERROR : NOVALUE;				!
;	  0128	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   5
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (3)

;	  0129	GLOBAL ROUTINE INISTG (AMOUNT) : NOVALUE = 	! INIT STORAGE MANAGER
;	  0130	
;	  0131	!++
;	  0132	! FUNCTIONAL DESCRIPTION:
;	  0133	!
;	  0134	!	ROUTINE TO INITIALIZE THE FREE STORAGE LIST.
;	  0135	!	AFTER INITIALIZATION IS COMPLETE A MINIMUM AMOUNT
;	  0136	!	OF STORAGE IS GUARANTEED AVAILABLE VIA GETSTG.
;	  0137	!
;	  0138	! FORMAL PARAMETERS:
;	  0139	!
;	  0140	!	AMOUNT - MIN FREE STORAGE PERMITTED
;	  0141	!
;	  0142	! IMPLICIT INPUTS:
;	  0143	!
;	  0144	!	NONE
;	  0145	!
;	  0146	! IMPLICIT OUTPUTS:
;	  0147	!
;	  0148	!	NONE
;	  0149	!
;	  0150	! ROUTINE VALUE:
;	  0151	!
;	  0152	!	NONE
;	  0153	!
;	  0154	! SIDE EFFECTS
;	  0155	!
;	  0156	!	MAY DO A CORE UUO TO GET STORAGE
;	  0157	!
;	  0158	!--
;	  0159	
;	  0160	    BEGIN
;	  0161	
;	  0162	    LOCAL
;	  0163		STG_POINTER;
;	  0164	
;	  0165	!
;	  0166	    INITIALIZED = 1;
;	  0167	    FSTG_ROOT [FSTG_NEXT] = 0;
;	  0168	
;	  0169	    IF ((STG_POINTER = GETSTG (.AMOUNT)) EQL 0)
;	  0170	    THEN
;	  0171		ERROR (UPLIT (%ASCIZ'NOT ENOUGH STORAGE FOR INITIALIZATION - INISTG'))
;	  0172	    ELSE
;	  0173		FRESTG (.STG_POINTER, .AMOUNT);
;	  0174	
;	  0175	    END;


	TITLE	STGM
	TWOSEG
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   6
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (3)


	.REQUEST  SYS:B362LB.REL


	RELOC	400000				;					400000'
P.AAA:	BYTE	(7)"N","O","T"," ","E"		; NOT E					400000' 116 117 124 040 105
	BYTE	(7)"N","O","U","G","H"		; NOUGH					400001' 116 117 125 107 110
	BYTE	(7)" ","S","T","O","R"		;  STOR					400002' 040 123 124 117 122
	BYTE	(7)"A","G","E"," ","F"		; AGE F					400003' 101 107 105 040 106
	BYTE	(7)"O","R"," ","I","N"		; OR IN					400004' 117 122 040 111 116
	BYTE	(7)"I","T","I","A","L"		; ITIAL					400005' 111 124 111 101 114
	BYTE	(7)"I","Z","A","T","I"		; IZATI					400006' 111 132 101 124 111
	BYTE	(7)"O","N"," ","-"," "		; ON -					400007' 117 116 040 055 040
	BYTE	(7)"I","N","I","S","T"		; INIST					400010' 111 116 111 123 124
	BYTE	(7)"G",000,000,000,000		; G					400011' 107 000 000 000 000


	RELOC	0				;					000000'
INITIALIZED:
	EXP	0				;					000000' 000000	000000
FSTG_ROOT:
	BLOCK	2				;					000001'
COUNTS: BLOCK	1001				;					000003'


	EXTERN	ERROR


AC0=	0
AC1=	1
AC2=	2
AC3=	3
AC4=	4
AC5=	5
AC6=	6
AC7=	7
AC10=	10
AC11=	11
AC12=	12
AC13=	13
AC14=	14
FP=	15
AC16=	16
SP=	17


	RELOC	400012				;					400012'
INISTG::MOVEI	AC1,1				; AC1,1					400012' 201 01 0 00 000001		0166
	MOVEM	AC1,INITIALIZED			; AC1,INITIALIZED			400013' 202 01 0 00 000000'
	HRRZS	FSTG_ROOT			; FSTG_ROOT				400014' 553 00 0 00 000001'		0167
	PUSH	SP,-1(SP)			; SP,AMOUNT				400015' 261 17 0 17 777777		0169
	PUSHJ	SP,GETSTG			; SP,GETSTG				400016' 260 17 0 00 000000V
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   7
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (3)

	ADJSP	SP,-1				; SP,-1					400017' 105 17 0 00 777777
	JUMPN	AC1,L.1				; STG_POINTER,L.1			400020' 326 01 0 00 400024'
	PUSH	SP,C.1				; SP,[0,,P.AAA]				400021' 261 17 0 00 400032'		0171
	PUSHJ	SP,ERROR			; SP,ERROR				400022' 260 17 0 00 000000*
	JRST	L.2				; L.2					400023' 254 00 0 00 400030'		0169
L.1:	PUSH	SP,AC1				; SP,STG_POINTER			400024' 261 17 0 00 000001		0173
	PUSH	SP,-2(SP)			; SP,AMOUNT				400025' 261 17 0 17 777776
	PUSHJ	SP,FRESTG			; SP,FRESTG				400026' 260 17 0 00 000000V
	ADJSP	SP,-1				; SP,-1					400027' 105 17 0 00 777777
L.2:	ADJSP	SP,-1				; SP,-1					400030' 105 17 0 00 777777		0160
	POPJ	SP,				; SP,					400031' 263 17 0 00 000000		0129
C.1:	XWD	0,P.AAA				; 0,P.AAA				400032' 000000	400000'

; Routine Size:  17 words


;	  0176	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   8
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (4)

;	  0177	ROUTINE GET_MORE_CORE (AMOUNT) = 		!GET CORE FROM END OF PROGRAM
;	  0178	
;	  0179	!++
;	  0180	! FUNCTIONAL DESCRIPTION:
;	  0181	!
;	  0182	!	GET CORE FROM THE END OF THE PROGRAM.
;	  0183	!	 THE PROGRAM WILL BE EXTENDED IF NECESSARY USING THE
;	  0184	!	 CORE UUO.
;	  0185	!
;	  0186	! FORMAL PARAMETERS:
;	  0187	!
;	  0188	!	AMOUNT - NUMBER OF WORDS TO GET
;	  0189	!
;	  0190	! IMPLICIT INPUTS:
;	  0191	!
;	  0192	!	.JBFF
;	  0193	!	.JBREL
;	  0194	!
;	  0195	! IMPLICIT OUTPUTS:
;	  0196	!
;	  0197	!	.JBFF
;	  0198	!	.JBREL
;	  0199	!
;	  0200	! ROUTINE VALUE:
;	  0201	!
;	  0202	!	A POINTER TO THE STORAGE GOTTEN, OR 0
;	  0203	!	 IF THE MONITOR WON'T GIVE US ANY MORE.
;	  0204	!
;	  0205	! SIDE EFFECTS
;	  0206	!
;	  0207	!	MAY DO A CORE UUO TO GET MORE CORE
;	  0208	!
;	  0209	!--
;	  0210	
;	  0211	    BEGIN
;	  0212	
;	  0213	    LOCAL
;	  0214		STG_POINTER,
;	  0215		TEMP;
;	  0216	
;	  0217	    EXTERNAL LITERAL
;	  0218		%NAME ('.JBFF'),
;	  0219		%NAME ('.JBREL');
;	  0220	
;	L 0221	%IF %SWITCHES(TOPS10)
;	U 0222	%THEN
;	U 0223	
;	U 0224	    BUILTIN
;	U 0225		UUO;
;	U 0226	
;	  0227	%FI
;	  0228	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page   9
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (4)

;	  0229	    REGISTER
;	  0230		R;
;	  0231	
;	  0232	    STG_POINTER = .(%NAME ('.JBFF'))<0, 18>;
;	  0233	    TEMP = .(%NAME ('.JBFF'))<0, 18> + .AMOUNT;
;	  0234	
;	  0235	    IF (.TEMP GEQ %O'400000')
;	  0236	    THEN
;	  0237		STG_POINTER = 0
;	  0238	    ELSE
;	  0239		BEGIN					!WE ARE UNDER 2**17 WORDS
;	  0240		%NAME ('.JBFF')<0, 18> = .TEMP;
;	  0241	
;	L 0242	%IF %SWITCHES(TOPS10)
;	U 0243	%THEN
;	U 0244	
;	U 0245		IF (.(%NAME ('.JBREL'))<0, 18> LSS .(%NAME ('.JBFF'))<0, 18>)
;	U 0246		THEN
;	U 0247		    BEGIN				!GET MORE CORE FROM MONITOR
;	U 0248		    R = .(%NAME ('.JBFF'))<0, 18>;
;	U 0249	
;	U 0250		    IF (UUO (1, %O'047', R, %O'11') EQL 0) THEN STG_POINTER = 0;
;	U 0251	
;	U 0252		    END;				! OF NEED TO GET MORE CORE FROM MONITOR
;	U 0253	
;	  0254	%FI
;	  0255	
;	  0256		END;
;	  0257	
;	  0258	    .STG_POINTER
;	  0259	    END;					!OF ROUTINE GET_MORE_CORE


	EXTERN	.JBFF, .JBREL


GET_MORE_CORE:
	HRRZ	AC1,.JBFF			; STG_POINTER,.JBFF			400033' 550 01 0 00 000000*		0232
	HRRZ	AC2,.JBFF			; TEMP,.JBFF				400034' 550 02 0 00 000000*		0233
	ADD	AC2,-1(SP)			; TEMP,AMOUNT				400035' 270 02 0 17 777777
	CAIL	AC2,400000			; TEMP,400000				400036' 301 02 0 00 400000		0235
	TDZA	AC1,AC1				; STG_POINTER,STG_POINTER		400037' 634 01 0 00 000001		0237
	HRRM	AC2,.JBFF			; TEMP,.JBFF				400040' 542 02 0 00 000000*		0240
	POPJ	SP,				; SP,					400041' 263 17 0 00 000000		0177

; Routine Size:  7 words


;	  0260	!
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  10
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (5)

;	  0261	ROUTINE SEARCH_CHAIN (AMT) = 			!SEARCH THE FREE STORAGE LIST
;	  0262	
;	  0263	!++
;	  0264	! FUNCTIONAL DESCRIPTION:
;	  0265	!
;	  0266	!	SEARCH THE FREE STORAGE LIST FOR A FREE BLOCK BIG ENOUGH
;	  0267	!	 TO SATISFY A REQUEST FOR AMT WORDS.
;	  0268	!
;	  0269	! FORMAL PARAMETERS:
;	  0270	!
;	  0271	!	AMT - NUMBER OF WORDS IN THE REQUEST
;	  0272	!
;	  0273	! IMPLICIT INPUTS:
;	  0274	!
;	  0275	!	THE FREE STORAGE LIST
;	  0276	!
;	  0277	! IMPLICIT OUTPUTS:
;	  0278	!
;	  0279	!	NONE
;	  0280	!
;	  0281	! ROUTINE VALUE:
;	  0282	!
;	  0283	!	A POINTER TO A SUITABLE BLOCK ON THE FREE LIST, OR
;	  0284	!	 0 IF NO BLOCK IS SUITABLE
;	  0285	!
;	  0286	! SIDE EFFECTS
;	  0287	!
;	  0288	!	NONE
;	  0289	!
;	  0290	!--
;	  0291	
;	  0292	    BEGIN
;	  0293	
;	  0294	    LOCAL
;	  0295		STG_PTR : REF ADDRESSES,
;	  0296		BEST_PTR : REF ADDRESSES;
;	  0297	
;	  0298	!
;	  0299	    STG_PTR = .FSTG_ROOT [FSTG_NEXT];
;	  0300	    BEST_PTR = 0;
;	  0301	
;	  0302	    WHILE (.STG_PTR NEQ 0) DO
;	  0303		BEGIN
;	  0304	
;	  0305		IF (.STG_PTR [FSTG_SIZE] GEQ .AMT)
;	  0306		THEN
;	  0307		    BEGIN				!REQUEST WILL FIT
;	  0308	
;	  0309		    IF (.BEST_PTR NEQ 0)
;	  0310		    THEN
;	  0311			BEGIN				!WE HAD A PREVIOUS FIT
;	  0312	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  11
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (5)

;	  0313			IF (.BEST_PTR [FSTG_SIZE] GTR .STG_PTR [FSTG_SIZE]) THEN BEST_PTR = .STG_PTR;
;	  0314	
;	  0315			END
;	  0316		    ELSE
;	  0317			BEST_PTR = .STG_PTR;
;	  0318	
;	  0319		    END;				!OF REQUEST WILL FIT
;	  0320	
;	  0321		STG_PTR = .STG_PTR [FSTG_NEXT];
;	  0322		END;					!OF SCAN OF FREE LIST
;	  0323	
;	  0324	    .BEST_PTR
;	  0325	    END;					!OF ROUTINE SEARCH_CHAIN


SEARCH_CHAIN:
	HLRZ	AC2,FSTG_ROOT			; STG_PTR,FSTG_ROOT			400042' 554 02 0 00 000001'		0299
	SETZ	AC1,				; BEST_PTR,				400043' 400 01 0 00 000000		0300
L.3:	JUMPE	AC2,L.6				; STG_PTR,L.6				400044' 322 02 0 00 400060'		0302
	HRRZ	AC3,0(AC2)			; AC3,0(STG_PTR)			400045' 550 03 0 02 000000		0305
	CAMGE	AC3,-1(SP)			; AC3,AMT				400046' 315 03 0 17 777777
	JRST	L.5				; L.5					400047' 254 00 0 00 400056'
	JUMPE	AC1,L.4				; BEST_PTR,L.4				400050' 322 01 0 00 400055'		0309
	HRRZ	AC3,0(AC1)			; AC3,0(BEST_PTR)			400051' 550 03 0 01 000000		0313
	HRRZ	AC4,0(AC2)			; AC4,0(STG_PTR)			400052' 550 04 0 02 000000
	CAMG	AC3,AC4				; AC3,AC4				400053' 317 03 0 00 000004
	JRST	L.5				; L.5					400054' 254 00 0 00 400056'
L.4:	MOVE	AC1,AC2				; BEST_PTR,STG_PTR			400055' 200 01 0 00 000002		0317
L.5:	HLRZ	AC2,0(AC2)			; STG_PTR,0(STG_PTR)			400056' 554 02 0 02 000000		0321
	JRST	L.3				; L.3					400057' 254 00 0 00 400044'		0302
L.6:	POPJ	SP,				; SP,					400060' 263 17 0 00 000000		0261

; Routine Size:  15 words


;	  0326	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  12
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (6)

;	  0327	GLOBAL ROUTINE GETSTG (AMOUNT) = 		!GET STORAGE
;	  0328	
;	  0329	!++
;	  0330	! FUNCTIONAL DESCRIPTION:
;	  0331	!
;	  0332	!	ROUTINE TO GET STORAGE.
;	  0333	!
;	  0334	! FORMAL PARAMETERS:
;	  0335	!
;	  0336	!	AMOUNT - NUMBER OF WORDS TO GET
;	  0337	!
;	  0338	! IMPLICIT INPUTS:
;	  0339	!
;	  0340	!	NONE
;	  0341	!
;	  0342	! IMPLICIT OUTPUTS:
;	  0343	!
;	  0344	!	NONE
;	  0345	!
;	  0346	! ROUTINE VALUE:
;	  0347	!
;	  0348	!	A POINTER TO THE STORAGE GOTTEN, OR 0 IF STORAGE EXHAUSTED
;	  0349	!
;	  0350	! SIDE EFFECTS
;	  0351	!
;	  0352	!	MAY DO A CORE UUO TO GET STORAGE
;	  0353	!
;	  0354	!--
;	  0355	
;	  0356	    BEGIN
;	  0357	
;	  0358	    LOCAL
;	  0359		AMT,
;	  0360		NEXT_PTR : REF ADDRESSES,
;	  0361		PREV_PTR : REF ADDRESSES,
;	  0362		THIS_PTR : REF ADDRESSES,
;	  0363		RESULT : REF VECTOR,
;	  0364		UNUSED_AMOUNT;
;	  0365	
;	  0366	    IF ( NOT .INITIALIZED)
;	  0367	    THEN
;	  0368		BEGIN
;	  0369		ERROR (UPLIT (%ASCIZ'CALL TO GETSTG BEFORE INISTG'));
;	  0370		0
;	  0371		END
;	  0372	    ELSE
;	  0373		BEGIN
;	  0374		AMT = .AMOUNT;				!AMOUNT OF STORAGE REQUESTED
;	  0375	
;	  0376		IF (((.AMT + 7)/8) GTR 512)
;	  0377		THEN
;	  0378		    COUNTS [512] = .COUNTS [512] + 1
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  13
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (6)

;	  0379		ELSE
;	  0380		    COUNTS [((.AMT + 7)/8)] = .COUNTS [((.AMT + 7)/8)] + 1;
;	  0381	
;	  0382	!
;	  0383	! ROUND STORAGE REQUEST UP TO COVER SPACE NEEDED FOR FREE STORAGE
;	  0384	!  CHAIN HEADERS.
;	  0385	!
;	  0386	
;	  0387		IF ((.AMT*%BPVAL) LSS (FSTG_HDRL*%BPADDR)) THEN AMT = ((FSTG_HDRL*%BPADDR) + (%BPVAL - 1))/%BPVAL;
;	  0388	
;	  0389	!
;	  0390	! SEARCH THE STORAGE CHAIN FOR A LARGE ENOUGH BLOCK
;	  0391	!
;	  0392	
;	  0393		IF ((THIS_PTR = SEARCH_CHAIN (.AMT)) EQL 0)
;	  0394		THEN
;	  0395		    BEGIN				!NOT ENOUGH SPACE ON THE FREE STORAGE CHAIN
;	  0396		    COLLECT_STORAGE ();			!TRY TO FIND SPACE BY COMBINING BLOCKS
;	  0397	
;	  0398		    IF ((THIS_PTR = SEARCH_CHAIN (.AMT)) EQL 0)
;	  0399		    THEN
;	  0400			BEGIN				!EVEN COMBINING BLOCKS ISN'T GOOD ENOUGH
;	  0401	
;	  0402			IF ((THIS_PTR = GET_MORE_CORE (.AMT)) NEQ 0) THEN FRESTG (.THIS_PTR, .AMT);
;	  0403	
;	  0404							!APPEND NEW STG TO FREE CHAIN
;	  0405			COLLECT_STORAGE ();		!BE SURE NEW BLOCK COMBINED WITH OLD ONES
;	  0406			THIS_PTR = SEARCH_CHAIN (.AMT);
;	  0407			END;
;	  0408	
;	  0409		    END;				!OF NOT ENOUGH STORAGE ON FREE CHAIN
;	  0410	
;	  0411	!
;	  0412	! WE HAVE THE STORAGE OR IT IS UNAVAILABLE
;	  0413	!
;	  0414	
;	  0415		IF (.THIS_PTR NEQ 0)
;	  0416		THEN
;	  0417		    BEGIN
;	  0418		    PREV_PTR = .THIS_PTR [FSTG_PREV];
;	  0419		    NEXT_PTR = .THIS_PTR [FSTG_NEXT];
;	  0420	
;	  0421		    IF (.NEXT_PTR NEQ 0) THEN NEXT_PTR [FSTG_PREV] = .PREV_PTR ELSE FSTG_ROOT [FSTG_PREV] = .PREV_PTR;
;	  0422	
;	  0423		    IF (.PREV_PTR NEQ 0) THEN PREV_PTR [FSTG_NEXT] = .NEXT_PTR ELSE FSTG_ROOT [FSTG_NEXT] = .NEXT_PTR;
;	  0424	
;	  0425		    IF (((UNUSED_AMOUNT = .THIS_PTR [FSTG_SIZE] - .AMT)*%BPVAL) GEQ (FSTG_HDRL*%BPADDR))
;	  0426		    THEN
;	  0427			BEGIN				!FREE UNUSED STORAGE IN THIS BLOCK
;	  0428			NEXT_PTR = .THIS_PTR + .AMT;
;	  0429			FRESTG (.NEXT_PTR, .UNUSED_AMOUNT);
;	  0430			END;
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  14
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (6)

;	  0431	
;	  0432		    RESULT = .THIS_PTR;
;	  0433	
;	  0434		    INCR COUNTER FROM 0 TO .AMT - 1 DO
;	  0435			RESULT [.COUNTER] = 0;
;	  0436	
;	  0437		    END;
;	  0438	
;	  0439		.THIS_PTR
;	  0440		END					!OF INITIALIZED
;	  0441	    END;


P.AAB:	BYTE	(7)"C","A","L","L"," "		; CALL					400061' 103 101 114 114 040
	BYTE	(7)"T","O"," ","G","E"		; TO GE					400062' 124 117 040 107 105
	BYTE	(7)"T","S","T","G"," "		; TSTG					400063' 124 123 124 107 040
	BYTE	(7)"B","E","F","O","R"		; BEFOR					400064' 102 105 106 117 122
	BYTE	(7)"E"," ","I","N","I"		; E INI					400065' 105 040 111 116 111
	BYTE	(7)"S","T","G",000,000		; STG					400066' 123 124 107 000 000


GETSTG::PUSH	SP,AC0				; SP,AC0				400067' 261 17 0 00 000000		0327
	PUSH	SP,AC10				; SP,AC10				400070' 261 17 0 00 000010
	MOVEI	AC0,1				; AC0,1					400071' 201 00 0 00 000001		0366
	TDNE	AC0,INITIALIZED			; AC0,INITIALIZED			400072' 612 00 0 00 000000'
	JRST	L.7				; L.7					400073' 254 00 0 00 400101'
	PUSH	SP,C.2				; SP,[0,,P.AAB]				400074' 261 17 0 00 400214'		0369
	PUSHJ	SP,ERROR			; SP,ERROR				400075' 260 17 0 00 000000*
	ADJSP	SP,-1				; SP,-1					400076' 105 17 0 00 777777		0368
	SETZ	AC1,				; AC1,					400077' 400 01 0 00 000000		0366
	JRST	L.18				; L.18					400100' 254 00 0 00 400211'
L.7:	MOVE	AC10,-3(SP)			; AMT,AMOUNT				400101' 200 10 0 17 777775		0374
	MOVE	AC1,AC10			; AC1,AMT				400102' 200 01 0 00 000010		0376
	ADDI	AC1,7				; AC1,7					400103' 271 01 0 00 000007
	IDIVI	AC1,10				; AC1,10				400104' 231 01 0 00 000010
	CAILE	AC1,1000			; AC1,1000				400105' 303 01 0 00 001000
	AOSA	COUNTS+1000			; COUNTS+1000				400106' 354 00 0 00 001003'		0378
	AOS	COUNTS(AC1)			; COUNTS(AC1)				400107' 350 00 0 01 000003'		0380
	MOVE	AC1,AC10			; AC1,AMT				400110' 200 01 0 00 000010		0387
	IMULI	AC1,44				; AC1,44				400111' 221 01 0 00 000044
	CAIGE	AC1,66				; AC1,66				400112' 305 01 0 00 000066
	MOVEI	AC10,2				; AMT,2					400113' 201 10 0 00 000002
	PUSH	SP,AC10				; SP,AMT				400114' 261 17 0 00 000010		0393
	PUSHJ	SP,SEARCH_CHAIN			; SP,SEARCH_CHAIN			400115' 260 17 0 00 400042'
	MOVE	AC0,AC1				; THIS_PTR,AC1				400116' 200 00 0 00 000001
	ADJSP	SP,-1				; SP,-1					400117' 105 17 0 00 777777
	JUMPN	AC0,L.9				; THIS_PTR,L.9				400120' 326 00 0 00 400145'
	PUSHJ	SP,COLLECT_STORAGE		; SP,COLLECT_STORAGE			400121' 260 17 0 00 000000V		0396
	PUSH	SP,AC10				; SP,AMT				400122' 261 17 0 00 000010		0398
	PUSHJ	SP,SEARCH_CHAIN			; SP,SEARCH_CHAIN			400123' 260 17 0 00 400042'
	MOVE	AC0,AC1				; THIS_PTR,AC1				400124' 200 00 0 00 000001
	ADJSP	SP,-1				; SP,-1					400125' 105 17 0 00 777777
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  15
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (6)

	JUMPN	AC0,L.9				; THIS_PTR,L.9				400126' 326 00 0 00 400145'
	PUSH	SP,AC10				; SP,AMT				400127' 261 17 0 00 000010		0402
	PUSHJ	SP,GET_MORE_CORE		; SP,GET_MORE_CORE			400130' 260 17 0 00 400033'
	MOVE	AC0,AC1				; THIS_PTR,AC1				400131' 200 00 0 00 000001
	ADJSP	SP,-1				; SP,-1					400132' 105 17 0 00 777777
	JUMPE	AC0,L.8				; THIS_PTR,L.8				400133' 322 00 0 00 400140'
	PUSH	SP,AC0				; SP,THIS_PTR				400134' 261 17 0 00 000000
	PUSH	SP,AC10				; SP,AMT				400135' 261 17 0 00 000010
	PUSHJ	SP,FRESTG			; SP,FRESTG				400136' 260 17 0 00 000000V
	ADJSP	SP,-2				; SP,-2					400137' 105 17 0 00 777776
L.8:	PUSHJ	SP,COLLECT_STORAGE		; SP,COLLECT_STORAGE			400140' 260 17 0 00 000000V		0405
	PUSH	SP,AC10				; SP,AMT				400141' 261 17 0 00 000010		0406
	PUSHJ	SP,SEARCH_CHAIN			; SP,SEARCH_CHAIN			400142' 260 17 0 00 400042'
	MOVE	AC0,AC1				; THIS_PTR,AC1				400143' 200 00 0 00 000001
	ADJSP	SP,-1				; SP,-1					400144' 105 17 0 00 777777		0400
L.9:	JUMPE	AC0,L.17			; THIS_PTR,L.17				400145' 322 00 0 00 400210'		0415
	MOVE	AC2,AC0				; AC2,THIS_PTR				400146' 200 02 0 00 000000		0418
	HRRZ	AC1,1(AC2)			; PREV_PTR,1(AC2)			400147' 550 01 0 02 000001
	MOVE	AC3,AC0				; AC3,THIS_PTR				400150' 200 03 0 00 000000		0419
	HLRZ	AC2,0(AC3)			; NEXT_PTR,0(AC3)			400151' 554 02 0 03 000000
	JUMPE	AC2,L.10			; NEXT_PTR,L.10				400152' 322 02 0 00 400155'		0421
	HRRM	AC1,1(AC2)			; PREV_PTR,1(NEXT_PTR)			400153' 542 01 0 02 000001
	JRST	L.11				; L.11					400154' 254 00 0 00 400156'
L.10:	HRRM	AC1,FSTG_ROOT+1			; PREV_PTR,FSTG_ROOT+1			400155' 542 01 0 00 000002'
L.11:	JUMPE	AC1,L.12			; PREV_PTR,L.12				400156' 322 01 0 00 400161'		0423
	HRLM	AC2,0(AC1)			; NEXT_PTR,0(PREV_PTR)			400157' 506 02 0 01 000000
	JRST	L.13				; L.13					400160' 254 00 0 00 400162'
L.12:	HRLM	AC2,FSTG_ROOT			; NEXT_PTR,FSTG_ROOT			400161' 506 02 0 00 000001'
L.13:	MOVE	AC1,AC0				; AC1,THIS_PTR				400162' 200 01 0 00 000000		0425
	HRRZ	AC3,0(AC1)			; UNUSED_AMOUNT,0(AC1)			400163' 550 03 0 01 000000
	SUB	AC3,AC10			; UNUSED_AMOUNT,AMT			400164' 274 03 0 00 000010
	MOVE	AC1,AC3				; AC1,UNUSED_AMOUNT			400165' 200 01 0 00 000003
	IMULI	AC1,44				; AC1,44				400166' 221 01 0 00 000044
	CAIGE	AC1,66				; AC1,66				400167' 305 01 0 00 000066
	JRST	L.14				; L.14					400170' 254 00 0 00 400177'
	MOVE	AC2,AC0				; NEXT_PTR,THIS_PTR			400171' 200 02 0 00 000000		0428
	ADD	AC2,AC10			; NEXT_PTR,AMT				400172' 270 02 0 00 000010
	PUSH	SP,AC2				; SP,NEXT_PTR				400173' 261 17 0 00 000002		0429
	PUSH	SP,AC3				; SP,UNUSED_AMOUNT			400174' 261 17 0 00 000003
	PUSHJ	SP,FRESTG			; SP,FRESTG				400175' 260 17 0 00 000000V
	ADJSP	SP,-2				; SP,-2					400176' 105 17 0 00 777776		0427
L.14:	MOVE	AC3,AC0				; RESULT,THIS_PTR			400177' 200 03 0 00 000000		0432
	SETO	AC2,				; COUNTER,				400200' 474 02 0 00 000000		0434
	JRST	L.16				; L.16					400201' 254 00 0 00 400205'
L.15:	MOVE	AC1,AC3				; AC1,RESULT				400202' 200 01 0 00 000003		0435
	ADD	AC1,AC2				; AC1,COUNTER				400203' 270 01 0 00 000002
	SETZM	0(AC1)				; 0(AC1)				400204' 402 00 0 01 000000
L.16:	ADDI	AC2,1				; COUNTER,1				400205' 271 02 0 00 000001		0434
	CAMGE	AC2,AC10			; COUNTER,AMT				400206' 315 02 0 00 000010
	JRST	L.15				; L.15					400207' 254 00 0 00 400202'
L.17:	MOVE	AC1,AC0				; AC1,THIS_PTR				400210' 200 01 0 00 000000		0366
L.18:	POP	SP,AC10				; SP,AC10				400211' 262 17 0 00 000010		0327
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  16
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (6)

	POP	SP,AC0				; SP,AC0				400212' 262 17 0 00 000000
	POPJ	SP,				; SP,					400213' 263 17 0 00 000000
C.2:	XWD	0,P.AAB				; 0,P.AAB				400214' 000000	400061'

; Routine Size:  86 words


;	  0442	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  17
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (7)

;	  0443	ROUTINE COLLECT_STORAGE : NOVALUE = 		!COMBINE STORAGE ON FREE LIST
;	  0444	
;	  0445	!++
;	  0446	! FUNCTIONAL DESCRIPTION:
;	  0447	!
;	  0448	!	THIS INTERNAL ROUTINE IS USED TO
;	  0449	!	 COMBINE ADJACENT BLOCKS ON THE FREE LIST INTO SINGLE
;	  0450	!	 BLOCKS.
;	  0451	!
;	  0452	!
;	  0453	! FORMAL PARAMETERS:
;	  0454	!
;	  0455	!	NONE
;	  0456	!
;	  0457	! IMPLICIT INPUTS:
;	  0458	!
;	  0459	!	THE FREE STORAGE LIST
;	  0460	!
;	  0461	! IMPLICIT OUTPUTS:
;	  0462	!
;	  0463	!	AN UPDATED FREE STORAGE LIST
;	  0464	!
;	  0465	! ROUTINE VALUE:
;	  0466	!
;	  0467	!	NONE
;	  0468	!
;	  0469	! SIDE EFFECTS
;	  0470	!
;	  0471	!	NONE
;	  0472	!
;	  0473	!--
;	  0474	
;	  0475	    BEGIN
;	  0476	
;	  0477	    LOCAL
;	  0478		NEXT_PTR : REF ADDRESSES,
;	  0479		PREV_PTR : REF ADDRESSES,
;	  0480		THIS_PTR : REF ADDRESSES;
;	  0481	
;	  0482	!
;	  0483	    PREV_PTR = .FSTG_ROOT [FSTG_NEXT];
;	  0484	
;	  0485	    IF (.PREV_PTR NEQ 0)
;	  0486	    THEN
;	  0487		BEGIN					!WE HAVE A FREE LIST
;	  0488	
;	  0489		WHILE ((THIS_PTR = .PREV_PTR [FSTG_NEXT]) NEQ 0) DO
;	  0490		    BEGIN				!SCAN THE FREE LIST
;	  0491	
;	  0492		    IF ((.PREV_PTR [FSTG_SIZE] + .PREV_PTR) EQL .THIS_PTR)
;	  0493		    THEN
;	  0494			BEGIN				!"PREV" AND "THIS" ARE ADJACENT
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  18
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (7)

;	  0495			NEXT_PTR = .THIS_PTR [FSTG_NEXT];
;	  0496			PREV_PTR [FSTG_SIZE] = .PREV_PTR [FSTG_SIZE] + .THIS_PTR [FSTG_SIZE];
;	  0497	
;	  0498			IF (.NEXT_PTR NEQ 0)
;	  0499			THEN
;	  0500			    BEGIN			!"THIS" IS NOT THE LAST ITEM IN THE FREE LIST
;	  0501			    PREV_PTR [FSTG_NEXT] = .NEXT_PTR;
;	  0502			    NEXT_PTR [FSTG_PREV] = .PREV_PTR;
;	  0503			    END
;	  0504			ELSE
;	  0505			    BEGIN			!"THIS" IS LAST IN FREE LIST
;	  0506			    PREV_PTR [FSTG_NEXT] = 0;
;	  0507			    FSTG_ROOT [FSTG_PREV] = .PREV_PTR;
;	  0508			    END;			!OF LAST IN FREE LIST PROCESSING
;	  0509	
;	  0510			THIS_PTR = .PREV_PTR;		!CHECK NEW BLOCK AGAINST NEXT
;	  0511			END;				!OF COMBINING ADJACENT BLOCKS
;	  0512	
;	  0513		    PREV_PTR = .THIS_PTR;		!GO ON TO NEXT BLOCK (UNLESS COMBINED)
;	  0514		    END;				!OF SCAN OF FREE LIST
;	  0515	
;	  0516		END;					!OF HAVING A FREE LIST
;	  0517	
;	  0518	    END;					!OF ROUTINE COLLECT_STORAGE


COLLECT_STORAGE:
	HLRZ	AC3,FSTG_ROOT			; PREV_PTR,FSTG_ROOT			400215' 554 03 0 00 000001'		0483
	JUMPE	AC3,L.23			; PREV_PTR,L.23				400216' 322 03 0 00 400243'		0485
L.19:	HLRZ	AC1,0(AC3)			; THIS_PTR,0(PREV_PTR)			400217' 554 01 0 03 000000		0489
	JUMPE	AC1,L.23			; THIS_PTR,L.23				400220' 322 01 0 00 400243'
	HRRZ	AC4,0(AC3)			; AC4,0(PREV_PTR)			400221' 550 04 0 03 000000		0492
	ADD	AC4,AC3				; AC4,PREV_PTR				400222' 270 04 0 00 000003
	CAME	AC4,AC1				; AC4,THIS_PTR				400223' 312 04 0 00 000001
	JRST	L.22				; L.22					400224' 254 00 0 00 400241'
	HLRZ	AC2,0(AC1)			; NEXT_PTR,0(THIS_PTR)			400225' 554 02 0 01 000000		0495
	HRRZ	AC4,0(AC3)			; AC4,0(PREV_PTR)			400226' 550 04 0 03 000000		0496
	HRRZ	AC5,0(AC1)			; AC5,0(THIS_PTR)			400227' 550 05 0 01 000000
	ADD	AC4,AC5				; AC4,AC5				400230' 270 04 0 00 000005
	HRRM	AC4,0(AC3)			; AC4,0(PREV_PTR)			400231' 542 04 0 03 000000
	JUMPE	AC2,L.20			; NEXT_PTR,L.20				400232' 322 02 0 00 400236'		0498
	HRLM	AC2,0(AC3)			; NEXT_PTR,0(PREV_PTR)			400233' 506 02 0 03 000000		0501
	HRRM	AC3,1(AC2)			; PREV_PTR,1(NEXT_PTR)			400234' 542 03 0 02 000001		0502
	JRST	L.21				; L.21					400235' 254 00 0 00 400240'		0498
L.20:	HRRZS	0(AC3)				; 0(PREV_PTR)				400236' 553 00 0 03 000000		0506
	HRRM	AC3,FSTG_ROOT+1			; PREV_PTR,FSTG_ROOT+1			400237' 542 03 0 00 000002'		0507
L.21:	MOVE	AC1,AC3				; THIS_PTR,PREV_PTR			400240' 200 01 0 00 000003		0510
L.22:	MOVE	AC3,AC1				; PREV_PTR,THIS_PTR			400241' 200 03 0 00 000001		0513
	JRST	L.19				; L.19					400242' 254 00 0 00 400217'		0489
L.23:	POPJ	SP,				; SP,					400243' 263 17 0 00 000000		0443

; Routine Size:  23 words
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  19
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (7)

;	  0519	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  20
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (8)

;	  0520	GLOBAL ROUTINE FRESTG (ADDRESS, AMOUNT) : NOVALUE = 	!FREE STORAGE
;	  0521	
;	  0522	!++
;	  0523	! FUNCTIONAL DESCRIPTION:
;	  0524	!
;	  0525	!	THIS ROUTINE RETURNS STORAGE TO THE FREE LIST
;	  0526	!
;	  0527	! FORMAL PARAMETERS:
;	  0528	!
;	  0529	!	ADDRESS - POINTER TO THE STORAGE TO FREE
;	  0530	!	AMOUNT - LENGTH OF THAT STORAGE
;	  0531	!
;	  0532	! IMPLICIT INPUTS:
;	  0533	!
;	  0534	!	THE FREE STORAGE LIST
;	  0535	!
;	  0536	! IMPLICIT OUTPUTS:
;	  0537	!
;	  0538	!	THE FREE STORAGE LIST
;	  0539	!
;	  0540	! ROUTINE VALUE:
;	  0541	!
;	  0542	!	NONE
;	  0543	!
;	  0544	! SIDE EFFECTS
;	  0545	!
;	  0546	!	NONE
;	  0547	!
;	  0548	!--
;	  0549	
;	  0550	    BEGIN
;	  0551	
;	  0552	    LOCAL
;	  0553		AMT,
;	  0554		NEXT_PTR : REF ADDRESSES,
;	  0555		STG_PTR : REF ADDRESSES,
;	  0556		FOUND_PLACE;
;	  0557	
;	  0558	    MAP
;	  0559		ADDRESS : REF ADDRESSES;
;	  0560	
;	  0561	!
;	  0562	    AMT = .AMOUNT;				!AMOUNT OF STORAGE REQUESTED
;	  0563	!
;	  0564	! ROUND STORAGE REQUEST UP TO COVER SPACE NEEDED FOR FREE STORAGE
;	  0565	!  CHAIN HEADERS.
;	  0566	!
;	  0567	
;	  0568	    IF ((.AMT*%BPVAL) LSS (FSTG_HDRL*%BPADDR)) THEN AMT = ((FSTG_HDRL*%BPADDR) + (%BPVAL - 1))/%BPVAL;
;	  0569	
;	  0570	!
;	  0571	! FIND PLACE TO INSERT THIS BLOCK IN THE FREE STORAGE LIST
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  21
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (8)

;	  0572	!
;	  0573	    STG_PTR = FSTG_ROOT;
;	  0574	    FOUND_PLACE = 0;
;	  0575	
;	  0576	    WHILE ((.STG_PTR NEQ 0) AND (.FOUND_PLACE EQL 0)) DO
;	  0577		BEGIN
;	  0578		NEXT_PTR = .STG_PTR [FSTG_NEXT];
;	  0579	
;	  0580		IF ((.NEXT_PTR NEQ 0) AND (.NEXT_PTR GTRA .ADDRESS)) THEN FOUND_PLACE = 1 ELSE STG_PTR = .NEXT_PTR;
;	  0581	
;	  0582		END;
;	  0583	
;	  0584	    IF (.STG_PTR EQL 0)
;	  0585	    THEN
;	  0586		BEGIN					!NEW BLOCK GOES AT END OF CHAIN
;	  0587		STG_PTR = .FSTG_ROOT [FSTG_PREV];
;	  0588		END;
;	  0589	
;	  0590	    ADDRESS [FSTG_SIZE] = .AMT;
;	  0591	    ADDRESS [FSTG_PREV] = (IF (.STG_PTR EQL FSTG_ROOT) THEN 0 ELSE .STG_PTR);
;	  0592	
;	  0593	    IF (.STG_PTR NEQ 0)
;	  0594	    THEN
;	  0595		BEGIN					!THERE IS AN OLD CHAIN
;	  0596		ADDRESS [FSTG_NEXT] = .STG_PTR [FSTG_NEXT];
;	  0597		NEXT_PTR = .STG_PTR [FSTG_NEXT];
;	  0598		STG_PTR [FSTG_NEXT] = .ADDRESS;
;	  0599	
;	  0600		IF (.NEXT_PTR NEQ 0) THEN NEXT_PTR [FSTG_PREV] = .ADDRESS ELSE FSTG_ROOT [FSTG_PREV] = .ADDRESS;
;	  0601	
;	  0602		END
;	  0603	    ELSE
;	  0604		BEGIN					!THIS IS ONLY ITEM ON LIST
;	  0605		ADDRESS [FSTG_NEXT] = 0;
;	  0606		FSTG_ROOT [FSTG_NEXT] = .ADDRESS;
;	  0607		FSTG_ROOT [FSTG_PREV] = .ADDRESS;
;	  0608		END;
;	  0609	
;	  0610	    COLLECT_STORAGE ();
;	  0611	    END;


FRESTG::MOVE	AC2,-1(SP)			; AMT,AMOUNT				400244' 200 02 0 17 777777		0562
	MOVE	AC1,AC2				; AC1,AMT				400245' 200 01 0 00 000002		0568
	IMULI	AC1,44				; AC1,44				400246' 221 01 0 00 000044
	CAIGE	AC1,66				; AC1,66				400247' 305 01 0 00 000066
	MOVEI	AC2,2				; AMT,2					400250' 201 02 0 00 000002
	MOVEI	AC4,FSTG_ROOT			; STG_PTR,FSTG_ROOT			400251' 201 04 0 00 000001'		0573
	SETZ	AC1,				; FOUND_PLACE,				400252' 400 01 0 00 000000		0574
L.24:	JUMPE	AC4,L.26			; STG_PTR,L.26				400253' 322 04 0 00 400265'		0576
	JUMPN	AC1,L.26			; FOUND_PLACE,L.26			400254' 326 01 0 00 400265'
	HLRZ	AC3,0(AC4)			; NEXT_PTR,0(STG_PTR)			400255' 554 03 0 04 000000		0578
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  22
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (8)

	JUMPE	AC3,L.25			; NEXT_PTR,L.25				400256' 322 03 0 00 400263'		0580
	CAMG	AC3,-2(SP)			; NEXT_PTR,ADDRESS			400257' 317 03 0 17 777776
	JRST	L.25				; L.25					400260' 254 00 0 00 400263'
	MOVEI	AC1,1				; FOUND_PLACE,1				400261' 201 01 0 00 000001
	JRST	L.24				; L.24					400262' 254 00 0 00 400253'
L.25:	MOVE	AC4,AC3				; STG_PTR,NEXT_PTR			400263' 200 04 0 00 000003
	JRST	L.24				; L.24					400264' 254 00 0 00 400253'		0576
L.26:	JUMPN	AC4,L.27			; STG_PTR,L.27				400265' 326 04 0 00 400267'		0584
	HRRZ	AC4,FSTG_ROOT+1			; STG_PTR,FSTG_ROOT+1			400266' 550 04 0 00 000002'		0587
L.27:	MOVE	AC1,-2(SP)			; AC1,ADDRESS				400267' 200 01 0 17 777776		0590
	HRRM	AC2,0(AC1)			; AMT,0(AC1)				400270' 542 02 0 01 000000
	CAIN	AC4,FSTG_ROOT			; STG_PTR,FSTG_ROOT			400271' 306 04 0 00 000001'		0591
	TDZA	AC2,AC2				; AC2,AC2				400272' 634 02 0 00 000002
	MOVE	AC2,AC4				; AC2,STG_PTR				400273' 200 02 0 00 000004
	HRRM	AC2,1(AC1)			; AC2,1(AC1)				400274' 542 02 0 01 000001
	JUMPE	AC4,L.28			; STG_PTR,L.28				400275' 322 04 0 00 400305'		0593
	HLRZ	AC2,0(AC4)			; AC2,0(STG_PTR)			400276' 554 02 0 04 000000		0596
	HRLM	AC2,0(AC1)			; AC2,0(AC1)				400277' 506 02 0 01 000000
	HLRZ	AC3,0(AC4)			; NEXT_PTR,0(STG_PTR)			400300' 554 03 0 04 000000		0597
	HRLM	AC1,0(AC4)			; AC1,0(STG_PTR)			400301' 506 01 0 04 000000		0598
	JUMPE	AC3,L.29			; NEXT_PTR,L.29				400302' 322 03 0 00 400307'		0600
	HRRM	AC1,1(AC3)			; AC1,1(NEXT_PTR)			400303' 542 01 0 03 000001
	JRST	L.30				; L.30					400304' 254 00 0 00 400310'
L.28:	HRRZS	0(AC1)				; 0(AC1)				400305' 553 00 0 01 000000		0605
	HRLM	AC1,FSTG_ROOT			; AC1,FSTG_ROOT				400306' 506 01 0 00 000001'		0606
L.29:	HRRM	AC1,FSTG_ROOT+1			; AC1,FSTG_ROOT+1			400307' 542 01 0 00 000002'		0607
L.30:	JRST	COLLECT_STORAGE			; COLLECT_STORAGE			400310' 254 00 0 00 400215'		0610

; Routine Size:  37 words


;	  0612	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  23
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (9)

;	  0613	GLOBAL ROUTINE GETBLK (BLOCK_TYPE, BLOCK_LENGTH) = 	!GET A BLOCK
;	  0614	
;	  0615	!++
;	  0616	! FUNCTIONAL DESCRIPTION:
;	  0617	!
;	  0618	!	THIS ROUTINE GETS A BLOCK AND FILLS IN ITS HEADER.
;	  0619	!
;	  0620	! FORMAL PARAMETERS:
;	  0621	!
;	  0622	!	BLOCK_TYPE - THE TYPE OF THE BLOCK TO GET
;	  0623	!	BLOCK_LENGTH - THE LENGTH OF THE BLOCK TO GET
;	  0624	!
;	  0625	! IMPLICIT INPUTS:
;	  0626	!
;	  0627	!	NONE
;	  0628	!
;	  0629	! IMPLICIT OUTPUTS:
;	  0630	!
;	  0631	!	NONE
;	  0632	!
;	  0633	! ROUTINE VALUE:
;	  0634	!
;	  0635	!	A POINTER TO THE BLOCK GOTTEN, OR 0 IF OUT OF STORAGE
;	  0636	!
;	  0637	! SIDE EFFECTS
;	  0638	!
;	  0639	!	MAY DO A CORE UUO TO GET STORAGE
;	  0640	!
;	  0641	!--
;	  0642	
;	  0643	    BEGIN
;	  0644	
;	  0645	    LOCAL
;	  0646		RESULT : REF ADDRESSES;
;	  0647	
;	  0648	!
;	  0649	
;	  0650	    IF ((RESULT = GETSTG (.BLOCK_LENGTH)) NEQ 0)
;	  0651	    THEN
;	  0652		BEGIN
;	  0653		RESULT [0] = .BLOCK_TYPE;
;	  0654		RESULT [1] = .BLOCK_LENGTH;
;	  0655		END;
;	  0656	
;	  0657	    .RESULT
;	  0658	    END;


GETBLK::PUSH	SP,-1(SP)			; SP,BLOCK_LENGTH			400311' 261 17 0 17 777777		0650
	PUSHJ	SP,GETSTG			; SP,GETSTG				400312' 260 17 0 00 400067'
	ADJSP	SP,-1				; SP,-1					400313' 105 17 0 00 777777
	JUMPE	AC1,L.31			; RESULT,L.31				400314' 322 01 0 00 400321'
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  24
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (9)

	MOVE	AC2,-2(SP)			; AC2,BLOCK_TYPE			400315' 200 02 0 17 777776		0653
	HRRM	AC2,0(AC1)			; AC2,0(RESULT)				400316' 542 02 0 01 000000
	MOVE	AC2,-1(SP)			; AC2,BLOCK_LENGTH			400317' 200 02 0 17 777777		0654
	HRLM	AC2,0(AC1)			; AC2,0(RESULT)				400320' 506 02 0 01 000000
L.31:	POPJ	SP,				; SP,					400321' 263 17 0 00 000000		0613

; Routine Size:  9 words


;	  0659	
;	  0660	!
;	  0661	
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  25
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (10)

;	  0662	GLOBAL ROUTINE FREBLK (ADDRESS) : NOVALUE = 	!FREE A BLOCK
;	  0663	
;	  0664	!++
;	  0665	! FUNCTIONAL DESCRIPTION:
;	  0666	!
;	  0667	!	THIS ROUTINE RETURNS A BLOCK GOTTEN BY GETBLK
;	  0668	!
;	  0669	! FORMAL PARAMETERS:
;	  0670	!
;	  0671	!	ADDRESS - POINTER TO THE BLOCK TO BE FREED
;	  0672	!
;	  0673	! IMPLICIT INPUTS:
;	  0674	!
;	  0675	!	NONE
;	  0676	!
;	  0677	! IMPLICIT OUTPUTS:
;	  0678	!
;	  0679	!	NONE
;	  0680	!
;	  0681	! ROUTINE VALUE:
;	  0682	!
;	  0683	!	NONE
;	  0684	!
;	  0685	! SIDE EFFECTS
;	  0686	!
;	  0687	!	NONE
;	  0688	!
;	  0689	!--
;	  0690	
;	  0691	    BEGIN
;	  0692	
;	  0693	    LOCAL
;	  0694		LEN;
;	  0695	
;	  0696	    MAP
;	  0697		ADDRESS : REF ADDRESSES;
;	  0698	
;	  0699	!
;	  0700	    LEN = .ADDRESS [1];
;	  0701	    FRESTG (.ADDRESS, .LEN);
;	  0702	    END;


FREBLK::MOVE	AC1,-1(SP)			; AC1,ADDRESS				400322' 200 01 0 17 777777		0700
	HLRZ	AC2,0(AC1)			; LEN,0(AC1)				400323' 554 02 0 01 000000
	PUSH	SP,AC1				; SP,AC1				400324' 261 17 0 00 000001		0701
	PUSH	SP,AC2				; SP,LEN				400325' 261 17 0 00 000002
	PUSHJ	SP,FRESTG			; SP,FRESTG				400326' 260 17 0 00 400244'
	ADJSP	SP,-2				; SP,-2					400327' 105 17 0 00 777776		0691
	POPJ	SP,				; SP,					400330' 263 17 0 00 000000		0662

; Routine Size:  7 words
STGM								25-Jan-1983 10:17:15	TOPS-20 Bliss-36 2A(142)	    Page  26
X2.0								 1-Jan-1983 15:40:20	NETPKG:<VNP36>STGM.BLI.7 (10)

;	  0703	
;	  0704	!
;	  0705	END
;	  0706	
;	  0707	ELUDOM



	END

; Low  segment length:     516 words
; High segment length:     217 words





;	  0708	! Local Modes:
;	  0709	! Comment Start:!
;	  0710	! Comment Column:36
;	  0711	! Mode:Fundamental
;	  0712	! Auto Save Mode:2
;	  0713	! End:
; Size:		201 code + 532 data words
; Run Time:	00:05.0
; Elapsed Time:	00:19.7
; Memory Used:	15 pages
; Compilation Complete
ADDRESS				 520	 559	 580	 590#	 591#	 596#	 598	 600	 605#	 606	 607	 662
				 697	 700	 701
ADDRESSES			  98#	 100	 119	 295	 296	 360	 361	 362	 478	 479	 480	 554
				 555	 559	 646	 697
AMOUNT				 129	 169	 173	 177	 233	 327	 374	 520	 562
AMT				 261	 305	 359	 374#	 376	 380	 387#	 393	 398	 402	 406	 425
				 428	 434	 553	 562#	 568#	 590
BEST_PTR			 296	 300#	 309	 313#	 317#	 324
BLOCK_LENGTH			 613	 650	 654
BLOCK_TYPE			 613	 653
COLLECT_STORAGE			  72	 396	 405	 443*	 610
COUNTER				 434	 435
COUNTS				 120	 378#	 380#
ERROR				 127*	 171	 369
FOUND_PLACE			 556	 574#	 576	 580#
FREBLK				  75#	 662*
FRESTG				  73	 173	 402	 429	 520*	 701
FSTG_HDRL			 111#	 119	 387	 425	 568
FSTG_NEXT			 109#	 167	 299	 321	 419	 423	 483	 489	 495	 501	 506	 578
				 596	 597	 598	 605	 606
FSTG_PREV			 110#	 418	 421	 502	 507	 587	 591	 600	 607
FSTG_ROOT			 119	 167#	 299	 421#	 423#	 483	 507#	 573	 587	 591	 600#	 606#
				 607#
FSTG_SIZE			 108#	 305	 313	 425	 492	 496	 590
GETBLK				  74	 613*
GETSTG				  71	 169	 327*	 650
GET_MORE_CORE			 177*	 402
INDEX				  98	 100
INISTG				  70	 129*
INITIALIZED			 118	 166#	 366
LEN				 694	 700#	 701
NEXT_PTR			 360	 419#	 421#	 423	 428#	 429	 478	 495#	 498	 501	 502#	 554
				 578#	 580	 597#	 600#
PREV_PTR			 361	 418#	 421	 423#	 479	 483#	 485	 489	 492	 496#	 501#	 502
				 506#	 507	 510	 513#
R				 230	 248#	 250
RESULT				 363	 432#	 435#	 646	 650#	 653#	 654#	 657
SEARCH_CHAIN			 261*	 393	 398	 406
STGM				   2#
STG_POINTER			 163	 169#	 173	 214	 232#	 237#	 250#	 258
STG_PTR				 295	 299#	 302	 305	 313	 317	 321#	 555	 573#	 576	 578	 580#
				 584	 587#	 591	 593	 596	 597	 598#
TEMP				 215	 233#	 235	 240
THIS_PTR			 362	 393#	 398#	 402#	 406#	 415	 418	 419	 425	 428	 432	 439
				 480	 489#	 492	 495	 496	 510#	 513
UNUSED_AMOUNT			 364	 425#	 429
UUO				 225	 250
VLENGTH				  98	  99