

; Bliss-32 10.1-416	Monday 21-AUG-1978 19:32:24	DBB3:[RTL.SRC]FVM.B32;7						Page 1

;

;00100  0001	MODULE FOR$$VM (	! Internal FORTRAM Virtual memory allocation/deallocation

;00200  0002		IDENT = '0-07'	! File: FVM.B32

;00300  0003			) =

;00400  0004	BEGIN

;00500  0005	

;00600  0006	!

;00700  0007	! Copyright (C) 1977

;00800  0008	! Digital Equipment Corporation,  Maynard, Massachusetts  01754

;00900  0009	!

;01000  0010	! This software is furnished under a license for use only on  a

;01100  0011	! single computer system and may be copied only with the inclu-

;01200  0012	! sion of the above copyright notice.  This  software,  or  any

;01300  0013	! other  copies  thereof, may not be provided or otherwise made

;01400  0014	! available to any other person except for use on  such  system

;01500  0015	! and  to  one who agrees to these license terms.  Title to and

;01600  0016	! ownership of the software shall at all times remain in DEC.

;01700  0017	!

;01800  0018	! The information in this software is subject to change without

;01900  0019	! notice and should not be construed as a commitment by Digital

;02000  0020	! Equipment Corporation.

;02100  0021	!

;02200  0022	! DEC assumes no responsibility for the use or  reliability  of

;02300  0023	! its software on equipment which is not supplied by DEC.

;02400  0024	!

;02500  0025	!++

;02600  0026	! FACILITY:FORTRAN support library

;02700  0027	!

;02800  0028	! ABSTRACT:  

;02900  0029	

;03000  0030	!	Dynamic virtual memory allocation and deallocation.

;03100  0031	!	FORTRAN interface with LIB$GET_VM and LIB$FREE_VM

;03200  0032	!	resourec allocation procedures.

;03300  0033	!

;03400  0034	! ENVIRONMENT: User access mode; mixture of AST level or not.

;03410  0035	!	       This module is both shared and non-shared.  Hence all

;03420  0036	!	       EXTERNAL references are of type GENERAL to prevent data truncation errors

;03430  0037	!	       when linking with the non-shared FORTRAN compatibility routines.

;03500  0038	!

;03600  0039	! AUTHOR:	T. Hastings, CREATION DATE: 4-Dec-77; Version 01

;03700  0040	!

;03800  0041	! MODIFIED BY:

;03900  0042	!

;04000  0043	! 01	- original 

;04100  0044	! 0-2	- Use FOR$$SIG_FATINT.  TNH 5-Dec-77

;04200  0045	! 0-3	- Don't clear memory.  TNH 8-Dec-77

;04300  0046	! 0-04	- Change REQUIRE files for VAX system build.  DGP 28-Apr-78

;04350  0047	! 0-05	- Add optional second arg (FCB only).  TNH 22-MAY-78

;04360  0048	! 0-06	- Use FOR$$SIG_DATCOR instead of FOR$$SIG_FATINT.  TNH 10-June-78

;04370  0049	! 0-07	- Make all external references GENERAL, since this module

;04380  0050	!	- is both shared and non-shared.  TNH 3-Aug-78

;04400  0051	!--



; Bliss-32 10.1-416	Monday 21-AUG-1978 19:32:24	DBB3:[RTL.SRC]FVM.B32;7						Page 2

;

;00100  0052	!

;00200  0053	! TABLE OF CONTENTS:

;00300  0054	!

;00400  0055	

;00500  0056	FORWARD ROUTINE

;00600  0057		FOR$$GET_VM,		! Allocate virtual memory - interface

;00700  0058		FOR$$FREE_VM: NOVALUE;	! Deallocate virtual memory - interface

;00800  0059	

;00900  0060	

;01000  0061	!

;01100  0062	! INCLUDE FILES:

;01200  0063	!

;01300  0064	

;01400  0065		REQUIRE 'RTLML:FERR';		! FORTRAN error numbers

; %PRINT:	Filename: FERR.MDL! Version 0, edit 36, TNH 19-June-78

;01500  0183		REQUIRE 'RTLIN:LPSECT';	! Define DECLARE_PSECTS macro

; %PRINT:	 REQUIRE FILE: LPSECT.B32, VERSION 01-5, TNH, 27-Jun-78

;01600  0237	

;01700  0238	!

;01800  0239	! MACROS:

;01900  0240	!

;02000  0241	!	NONE

;02100  0242	!

;02200  0243	! EQUATED SYSMBOLS:

;02300  0244	!

;02400  0245	

;02500  0246	

;02600  0247	!

;02700  0248	! PSECT DECLARATIONS:

;02800  0249	!

;02900  0250	

;03000  0251		DECLARE_PSECTS (FOR);	! declare PSECTs for FOR$ facility

;03100  0252	

;03200  0253	!

;03300  0254	! OWN STORAGE:

;03400  0255	!

;03500  0256	

;03600  0257	! EXTERNAL REFERENCES:

;03700  0258	!

;03800  0259	EXTERNAL ROUTINE

;03810  0260	

;03820  0261	!+

;03830  0262	! MAINTENANCE NOTE:  Since this module is called by FORTRAN compatibility

;03840  0263	! routines which are un-shared and the entry points are not vectored,

;03850  0264	! a separate copy of this module is linked with the user program when

;03860  0265	! the user calls a FORTRAN compatibility routine.  In order to prevent

;03870  0266	! data truncation errors from the linker, all external references are

;03880  0267	! of addressing mode general (rather than word displacement) even for

;03885  0268	! the same PSECT.

;03890  0269	!-

;03895  0270	

;03900  0271		FOR$$SIGNAL_STO: ADDRESSING_MODE (GENERAL) NOVALUE,	! FORTRAN SIGNAL_STOP for current unit

;04000  0272		FOR$$SIG_DATCOR: ADDRESSING_MODE (GENERAL) NOVALUE,	! FORTRAN SIGNAL_STOP OTS$_INTDATCOR

;04100  0273									! INTERNAL DATA CORRUPTED IN RUN-TIME LIBRARY

;04150  0274		FOR$$SIG_NO_LUB: ADDRESSING_MODE (GENERAL) NOVALUE,	! FORTRAN SIGNAL_STOP when no current LUB/ISB/RAB allocated



; Bliss-32 10.1-416	Monday 21-AUG-1978 19:32:24	DBB3:[RTL.SRC]FVM.B32;7						Page 2-1

;

;04200  0275		LIB$GET_VM: ADDRESSING_MODE (GENERAL),	! LIBRARY allocate virtual memory

;04300  0276		LIB$FREE_VM: ADDRESSING_MODE (GENERAL); ! LIBRARY deallocate virtual memory

;04400  0277	



; Bliss-32 10.1-416	Monday 21-AUG-1978 19:32:24	DBB3:[RTL.SRC]FVM.B32;7						Page 3

;

;00100  0278	GLOBAL ROUTINE FOR$$GET_VM (	! Allocate dynamic virtual memory

;00200  0279		NUM_BYTES,		! longword size in bytes

;00250  0280		LOGICAL_UNIT)		! optional logical unit (if LUB/ISB/RAB not allocated)

;00300  0281		=

;00400  0282	

;00500  0283	!++

;00600  0284	! FUNCTIONAL DESCRIPTION:

;00700  0285	!

;00800  0286	!       Allocates n virtually contiguous bytes at an arbitrary  place  in

;00900  0287	!       the  program  region and returns the virtual address of the first byte.

;01000  0288	!	See description of library LIB$GET_VM for details.

;01100  0289	!	This procedure is provided only for convenience to FORTRAN support library.

;01200  0290	!	It checks for errors and SIGNAL_STOPs any.

;01300  0291	!	It does not clear core for speed.

;01400  0292	!  

;01500  0293	!  CALLING SEQUENCE:

;01600  0294	!  

;01700  0295	!	ALLOC_ADR.wa.v = FOR$$GET_VM (NUM_BYTES.rlu.v [, logical_unit.rlu.v])

;01800  0296	!  

;01900  0297	!  INPUT PARAMETERS:

;02000  0298	!  

;02100  0299	!       num_bytes is  an  unsigned   longword   integer value

;02200  0300	!                 specifying  the number of virtually contiguous bytes to

;02300  0301	!                 be  allocated.   Sufficient  pages  are  allocated   to

;02400  0302	!                 satisfy  the  request.  however, the program should not

;02500  0303	!                 reference  before  the  first  byte  address   assigned

;02600  0304	!                 (base_address)    beyond   the   last   byte   assigned

;02700  0305	!                 (base_adr+num_bytes - 1) since it may  be  assigned  to

;02800  0306	!                 another procedure.

;02900  0307	!  

;02910  0308	!	[logical_unit.rlu.v] Optional logical unit number.  Used only if

;02920  0309	!			an error occurs and LUB/ISB/RAB is not already allocated.

;02930  0310	!

;03000  0311	!  OUTPUT PARAMETERS:

;03100  0312	!  

;03200  0313	!	None.

;03300  0314	!  

;03400  0315	!  IMPLICIT INPUTS:

;03500  0316	!  

;03600  0317	!	OTS$$A_CUR_LUB contains the address of the current LUB/ISB/RAB

;03700  0318	!	for which any errors detected will be signaled.

;03800  0319	!	See also LIB$GET_VM.

;03900  0320	!  

;04000  0321	!  IMPLICIT OUTPUTS:

;04100  0322	!  

;04200  0323	!	See LIB$GET_VM.

;04300  0324	!

;04400  0325	!  FUNCTION VALUE:

;04500  0326	!

;04600  0327	!	The address of the block allocated is returned

;04700  0328	!	as the function value.

;04800  0329	!

;04900  0330	!  SIDE EFFECTS:

;05000  0331	!

;05100  0332	!	The following errors are SIGNAL_STOPped:



; Bliss-32 10.1-416	Monday 21-AUG-1978 19:32:24	DBB3:[RTL.SRC]FVM.B32;7						Page 3-1

;

;05200  0333	!

;05300  0334	!       FOR$_INSVIRMEM indicates 'INSUFFICIENT VIRTUAL MEMORY' when the

;05400  0335	!       program

;05500  0336	!       region was attempted to be expanded.

;05600  0337	!       OTS$_INTDATCOR indicates 'BAD BLOCK SIZE either 0 oor

;05700  0338	!       larger than FOR$K_MXVMBLK.

;05800  0339	!       No partial assignment is made.

;05900  0340	!       An appropriate number of virtual byes are removed from the  image

;06000  0341	!       free  memory  list.   If needed the program region is expanded by

;06100  0342	!       calling the SYS$EXPREG system service.  if too large  a  size  is

;06200  0343	!       requested or the program region could not be expended as needed.

;06300  0344	!--

;06400  0345	

;06500  0346	    BEGIN

;06510  0347	    BUILTIN

;06520  0348		ACTUALCOUNT;

;06600  0349	    LOCAL

;06700  0350		TEMP_ADR;	! Adr. of block allocated

;06800  0351	    IF NOT LIB$GET_VM (NUM_BYTES, TEMP_ADR)

;06805  0352	    THEN 

;06815  0353		BEGIN

;06825  0354		IF ACTUALCOUNT() GTRU 1

;06835  0355		THEN

;06845  0356		    FOR$$SIG_NO_LUB (FOR$K_INSVIRMEM, .LOGICAL_UNIT)

;06855  0357		ELSE

;06865  0358		    FOR$$SIGNAL_STO (FOR$K_INSVIRMEM)

;06875  0359		END;

;06900  0360	    RETURN .TEMP_ADR;

;07000  0361	    END;		!  end of FOR$GET_VM routine





							    .TITLE  FOR$$VM

							    .IDENT  \0-07\



							    .EXTRN  FOR$$SIGNAL_STO, FOR$$SIG_DATCOR, FOR$$SIG_NO_LUB

							    .EXTRN  LIB$GET_VM, LIB$FREE_VM



							    .PSECT  FOR$CODE,NOWRT,  SHR,  PIC,2



					 0000 00000 	    .ENTRY  FOR$$GET_VM, Save nothing				      ; 0278

		         5E 	       04  C2 00002 	    SUBL2   #4, SP						      ;

				       5E  DD 00005 	    PUSHL   SP							      ; 0351

				  04   AC  9F 00007 	    PUSHAB  NUM_BYTES						      ;

	      00000000G  00	       02  FB 0000A 	    CALLS   #2, LIB$GET_VM					      ;

		         1C 	       50  E8 00011 	    BLBS    R0, 2$						      ;

		         01 	       6C  91 00014 	    CMPB    (AP), #1						      ; 0354

				       0E  1B 00017 	    BLEQU   1$							      ;

				  08   AC  DD 00019 	    PUSHL   LOGICAL_UNIT					      ; 0356

				       29  DD 0001C 	    PUSHL   #41							      ;

	      00000000G  00	       02  FB 0001E 	    CALLS   #2, FOR$$SIG_NO_LUB					      ;

				       09  11 00025 	    BRB     2$							      ; 0353

				       29  DD 00027 1$:     PUSHL   #41							      ; 0358

	      00000000G  00	       01  FB 00029 	    CALLS   #1, FOR$$SIGNAL_STO					      ;

		         50 	       6E  D0 00030 2$:     MOVL    TEMP_ADR, R0					      ; 0360

					   04 00033 	    RET     							      ; 0278



; Bliss-32 10.1-416	Monday 21-AUG-1978 19:32:24	DBB3:[RTL.SRC]FVM.B32;7						Page 3-2

;



; Routine Size:  52 bytes







; Bliss-32 10.1-416	Monday 21-AUG-1978 19:32:24	DBB3:[RTL.SRC]FVM.B32;7						Page 4

;

;00100  0362	GLOBAL ROUTINE FOR$$FREE_VM (		! Internal FORTRAN deallocate virtual memory

;00200  0363			NUM_BYTES,		! size in bytes

;00300  0364			BASE_ADR)		! Adr. of block to be deallocated

;00400  0365		: NOVALUE	=

;00500  0366	

;00600  0367	!++

;00700  0368	!  FUNCTIONAL DESCRIPTION:

;00800  0369	!  

;00900  0370	!       Deallocates  n  virtually  contiguous  bytes  starting   at   the

;01000  0371	!       specified   virtual   address.   The  number  of  bytes  actually

;01100  0372	!       allocated is rouned up so that the smallest number of whole  quad

;01200  0373	!       words  are  de-allocated.  Numerous error checks are made to make

;01300  0374	!       sure that the block being returned is a legimate free area.

;01400  0375	!  

;01500  0376	!  CALLING SEQUENCE:

;01600  0377	!  

;01700  0378	!       CALL FOR$$FREE_VM(num_bytes.rlu.v, base_adr.ra.v)

;01800  0379	!  

;01900  0380	!  INPUT PARAMETERS:

;02000  0381	!  

;02100  0382	!       num_bytes is  an  unsigned   integer

;02200  0383	!                 specifying  the number of virtually contiguous bytes to

;02300  0384	!                 be deallocated.

;02400  0385	!  

;02500  0386	!       base_adr  is the address of

;02600  0387	!                 the first byte to be deallocated.

;02700  0388	!  

;02800  0389	!  OUTPUT PARAMETERS:

;02900  0390	!  

;03000  0391	!  None.

;03100  0392	!  

;03200  0393	!  IMPLICIT INPUTS

;03300  0394	!  

;03400  0395	!	OTS$$A_CUR_LUB contains the address of the current LUB/ISB/RAB

;03500  0396	!	for which the storage is being returned.  Any errors

;03600  0397	!	are signaled on the logical unit.

;03700  0398	!  

;03800  0399	!  IMPLICIT OUTPUTS

;03900  0400	!  

;04000  0401	!       The pages are deallocated by calling $DEALTVA.   Then  the  pages

;04100  0402	!       are  marked  as  available  in  the  OWN  storage  maintained  by

;04200  0403	!       LIB$GET_VM.

;04300  0404	!  

;04400  0405	!  COMPLETION STATUS:

;04500  0406	!  

;04600  0407	!	None.

;04700  0408	!

;04800  0409	!  SIDE EFFECTS:

;04900  0410	!

;05000  0411	!	Any errors are signal_stopped on the current logical unit.

;05100  0412	!       OTS$_INTDATCOR  indicates BAD BLOCK ADDRESS

;05200  0413	!  

;05300  0414	!     PUTS the indicated block back on the image free storage list.

;05400  0415	!--

;05500  0416	



; Bliss-32 10.1-416	Monday 21-AUG-1978 19:32:24	DBB3:[RTL.SRC]FVM.B32;7						Page 4-1

;

;05600  0417	    BEGIN

;05700  0418	

;05800  0419	    !+

;05900  0420	    ! Deallocate virtual memory,  SIGNAL_STOP OTS$_INTDATCOR if error

;06000  0421	    !-

;06100  0422	

;06200  0423	    IF NOT LIB$FREE_VM (NUM_BYTES, BASE_ADR) THEN FOR$$SIG_DATCOR ();

;06300  0424	    END;











					 0000 00034 	    .ENTRY  FOR$$FREE_VM, Save nothing				      ; 0362

				  08   AC  9F 00036 	    PUSHAB  BASE_ADR						      ; 0423

				  04   AC  9F 00039 	    PUSHAB  NUM_BYTES						      ;

	      00000000G  00	       02  FB 0003C 	    CALLS   #2, LIB$FREE_VM					      ;

		         07 	       50  E8 00043 	    BLBS    R0, 1$						      ;

	      00000000G  00	       00  FB 00046 	    CALLS   #0, FOR$$SIG_DATCOR					      ;

					   04 0004D 1$:     RET     							      ; 0362



; Routine Size:  26 bytes





;06400  0425	END

;06500  0426	ELUDOM













;				       PSECT SUMMARY

;

;	Name		 Bytes			       Attributes

;

;  FOR$CODE       	    78  NOWRT,  RD ,  EXE,  SHR,  LCL,  REL,  CON,  PIC,ALIGN(2)











; Size:		78 code + 0 data bytes

; Run Time:	00:03.4

; Elapsed Time:	00:17.3

; Memory Used:	23 pages

; Compilation Complete

