	.TITLE	SHARE -- SUBROUTINE TO ENABLE XVM MEMORY SHARING
/
/ COPYRIGHT (C) 1975
/ DIGITAL EQUIPMENT CORPORATION, MAYNARD, MA. 01754, U.S.A.
/
/ THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
/ ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
/ THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/ SOFTWARE, OR ANY OTHER COPIES THEREOF, AMY NOT BE PRO-
/ VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
/ EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
/ THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/ SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
/ WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/ MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/ DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/ OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
/
	.EJECT
/
/
/ 000  11-JUL-75	KENT BLACKETT
/
/ 001  23-DEC-75	KENT BLACKETT	FIX BUG IN SIXBIT CONVERSION
/					OF PARTITION NAME.
/
/
/
/ SUBROUTINE TO ENABLE THE MEMORY SHARING FEATURE OF
/ THE XVM HARDWARE MEMORY MANAGEMENT UNIT.
/
/ CALLING SEQUENCE:
/
/     CALL SHARE(ANAME,IOFF,LEN,IACC,IEV)
/
/ WHERE:
/  ANAME  IS A REAL OR DOUBLE INTEGER CONSTAND OR VARIABLE
/         WHICH CONTAINS THE NAME OF THE PARTITION OR SYSTEM
/         COMMON BLOCK TO BE SHARED.
/  IOFF   IS AN INTEGER VARIABLE OR CONSTANT WHICH IS THE 
/         OFFSET INTO SAID PARTITION OR COMMON BLOCK
/         WHERE THE SHARED REGION BEGINS.  THE OFFSET
/         IS SPECIFIED IN WORDS, AND MUST BE AN EVEN
/         MULTIPLE OF 256(10), 400(8).
/  LEN    IS AN INTEGER CONSTANT OR VARIABLE WHICH IS
/         THE LENGTH IN WORDS OF THE SARED SEGMENT.
/         WITH THE CURRENT HARDWARE, THIS MUST BE ONE
/         OF THE FOLLOWING VALUES:
/		VALUE	LENGTH
/		  0	  NONE
/		  1	   256
/		  2	   768
/		  3	  3840
/		  4	  7936
/  IACC   IS AN INTEGER CONSTANT OR VARIABLE SPECIFYING
/         THE DESIRED ACCESS TO THE SHARED AREA.
/         IF THE VALUE IS EVEN, ACCESS IS READ ONLY.
/         IF THE VALUE IS ODD, ACESS IS READ/WRITE.
/  IEV    IS AN OPTIONAL INTEGER VARIABLE IN WHICH THE
/         EVENT VARIABLE WILL BE RETURN UPON COMPLETION
/         OF THE DIRECTIVE.
/
/
/ ERROR CODES ARE RETURNED IN IEV AS FOLLOWS:
/
/	CODE	MEANING
/	 -32	PARTITION OR SYSTEM COMMON BLOCK NOT IN
/		SYSTEM, OR IS PROTECTED AGAINST SHARING.
/	 -77	ACCESS TYPE DESIRED NOT CONSISTENT WITH
/		ACCESS TYPES PERMITTED.
/	-104	OFFSET NOT MULTIPLE OF 400(8) OR ILLEGAL
/		LENGTH CODE SPECIFIED OR BASE PLUS
/		OFFSET PLUS LENGTH OUTSIDE SHARED
/		PARTITION OR COMMON BLOCK.
/	-203	DIRECTIVE NOT TASK ISSUED.
/
/
	.EJECT
	.GLOBL	SHARE,.DA
SHARE	0			/ENTRY POINT
	JMS*	.DA		/ GET ARGUMENTS
	JMP	.+1+5
ANAME	.DSA	0		/ POINTER TO PART. NAME
IOFF	.DSA	0		/ POINTER TO OFFSET
LEN	.DSA	0		/ POINTER TO LENGTH CODE
IACC	.DSA	0		/ POINTER TO ACCESS CODE
IEV	.DSA	0		/ ADDRESS OF EVENT VARIABLE
/
/
/
	LAW	774000		/ CONVERT PART. NAME TO .SIXBT
	AND*	ANAME		/ FIRST CHAR
	RCL
	DAC	CPB+2		/ SET IT IN CPB
	LAC*	ANAME		/ SECOND CHAR
	DAC	CPB+4		/ USING CPB+4 AS A TEMPORARY
	AND	(001760)	/(RKB-001) STRIP OUT CHAR
	CLL!RTL			/ POSTION FOR SIXBT
	SAD	(004000)	/ IS IT A BLANK?
	CLA			/ YES, CALL IT A NULL
	XOR	CPB+2		/ COMBINE WITH FIRST
	DAC	CPB+2		/ PUT THEM BACK
	ISZ	ANAME		/ POINT TO SECOND HAVE OF 5/7 PAIR
	LAC*	ANAME		/ GET SECOND WORD
	LMQ
	LAC	CPB+4		/ RECALL FIRST WORD
	LLS	3		/ EXTRACT THIRD CHAR
	AND	(77)		/ CLEAR IT UP
	SAD	(40)		/ SPACE?
	CLA			/ YES, WE USE NULLS
	XOR	CPB+2		/ COMBINE WITH OTHER TWO
	DAC	CPB+2		/ DONE WITH CPB+2
	LLS	7		/ GET FOURTH CHAR
	AND	(77)		/ CLEAN IT
	SAD	(40)		/ SPACE?
	CLA			/ ITS A NULL NOW
	ALSS	14		/ MOVE TO 0:5
	DAC	CPB+3		/ NEXT WORD
	LLS	7		/ GET FIFTH AND FINAL WORD
	AND	(77)		/ STRIP GARBAGE
	SAD	(40)		/ SPACE?
	CLA
	ALSS	6		/MOVE TO RIGHT PLACE
	XOR	CPB+3		/ COMBINE WITH OTHER ONE
	DAC	CPB+3		/ THATS IT FOR THE NAME
/
/
	LAC*	IOFF		/ GET THE OFFSET
	DAC	CPB+4		/ THE EXEC WILL VALIDATE IT
/
/
	LAC*	LEN		/ GET THE LENGTH CODE
	AAC	-5		/ IS IT > 4?
	SMA			/ SKIP IF NO
	JMP	ERR104		/ YES, BAD NEWS
	TAD	(LENTBL+5)	/ GOING TO CONVERT IT
	DAC	CPB+5		/
	LAC*	CPB+5		/ USING CPB+5 AS A TEMPORARY
	DAC	CPB+5		/ THATS WHERE IT GOES
/
/
	LAC*	IACC		/ GET THE ACEDS COSE
	AND	(1)		/ ONLY INTERESTED IN BIT 17
	CLL!RTR			/ MOVE IT TO BIT 0
	XOR	CPB+5		/ COMBINE WITH LENGTH
	DAC	CPB+5		/ THATS ALL THERE IS TO IT
/
/
	LAC	IEV		/ EVENT VAR. ADDR. OR 0 IF NONE
	DAC	CPB+1		/ JUST THE WAY THE EXEC WANTS IT
/
/
	CAL	CPB		/ ISSUE THE 'SHARE' DIRECTIVE
/
/
	JMP*	SHARE		/ NOTE THAT NO 'WAITFOR' IS REQUIRED
/
/
ERR104	LAC	IEV		/ DID CALLER SPECIFY AN EVENT VARIABLE?
	SNA			/ SKIP IF YES
	JMP*	SHARE		/ NO, CAN'T VERY WELL RETURN AN ERROR CODE
	LAW	-104		/ YES, ILLEGAL LENGTH SPECIFIED.
	DAC*	IEV		/ SET IT FOR HIM
	JMP*	SHARE		/ AND EXIT
/
/
CPB	35			/ SHARE CPB
	0			/ EVENT VARIABLE ADDRESS
	0			/ PARTITION NAME, WORD 1
	0			/ PARTITION NAME WORD 2
	0			/ OFFSET FROM BASE ADDR OF PART.
	0			/ LENGTH PLUS ACCESS IN BIT 0
/
/
LENTBL	0			/ DISABLE SHARING
	400			/ LENGTH OF 256
	1400			/ LENGTH OF 768
	7400			/ LENGTH OF 3840
	17400			/ LENGTH OF 7936
	.END
