	.TITLE	DYS
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/
/ EDIT #05	7/16/73		S. ROOT
/	UPDATE COPYRIGHT
/
/ PROGRAM CODE UNKNOWN
/
/ COPYRIGHT 1972, 1973, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.,  01754
/
/	RELOCATING ROUTINES TO CONVERT DISPLAY FILES CREATED
/ BY RSX-15 GRAPHICS TO RELOCATABLE FORM FOR STORAGE, AND TO
/ CONVERT BACK TO EXECUTABLE FORM. THESE ROUTINES WILL NOT
/ WORK WITH FILES SAVED UNDER DOS-15. NEITHER IS THE CALLING
/ SEQUENCE THE SAME AS THAT UNDER DOS-15.
/
	.EBREL
/
/  ENTRY POINTS IN THE PRIMITIVES TO GET PARTITION BASE ADDRESS
/  AND THE ADDRESS IN THE SCOPE HANDER OF THE LIGHT PEN
/  ENABLE SUBROUTINE.
/
	.GLOBL VTGL1,VTGL2,VTGL3
/
/  ENTRY POINTS
/
	.GLOBL DYSET,DYLINK
/
/  SOME GRAPHICS EQUALITIES
/
DSAVR=240000
DJMP=600000
DJMS=640000
DSKP=235000
DCHAR=40000
/
/  STORAGE LOCATIONS
/  ABS REFERS TO AN ABSOLUTE LOCATIONS
/  REL(P) REFERS TO RELATIVE TO PARTITION BASE ADDRESS
/  REL(F) REFERS TO RELATIVE TO TOP OF FILE ADDRESS
/
/
TEMP	0	/TEMPORARY FOR ADDRESS CALCULATIONS ETC.
POINT	0	/POINTER TO INSTRUCTION IN DISPLAY FILE (REL(P))
FA13	0	/13 BIT TOP OF FILE ADDR. NEG=DYSET.POS=DYLINK.
/		/THIS ADDRESS IS ABSOLUTE!
FILEP	0	/POINTER TO ARGUMENT LIST TO FILE CURRENTLY
/		/BEING SCANNED FOR MEMORY REFERENCES.
FILE	0	/REAL ADDR OF FILE (REL(P))
BOTTOM	0	/ADDRESS OF END OF SAME FILE (REL(P))
MEM	0	/ADDRESS REFERENCED BY INSTRUCTION POINTED TO
/		/BY POINT.  (REL(P))
BASE	0	/ADDRESS OF BEGINNING OF THIS PARTITION (ABS)
LTP	0	/ADDRESS OF LIGHT PEN ENABLE ROUTINE (ABS)
ARGP	0	/POINTER TO ARG. LIST FOR FINDING THE FILE
/		/REFERENCED INDIRECTLY THRU MEM (REL(P))
ENDDSP	0	/POINTER TO LOCATION AFTER LAST DISPLAY FILE
/		/(NOT TEXT!) IN ARGUMENT LIST (REL(P))
ENDTXT	0	/POINTER TO LOCATION AFTER LAST ARGUMENT (REL(P))
/
/
/  SUBROUTINE TO CORRECT FOR EXTRA INDIRECTION IN PROVIDED ARRAY
/
JUST	0		/CALL WITH ADDR IN AC
	SMA
	JMP*	JUST	/ADDR NOT NEG., IS OK.
	DAC	JUSTT	/XTRA INDIRECTION
	LAC*	JUSTT
	JMP*	JUST
JUSTT	0		/TEMPORARY FOR JUST
/
/
/  ENTRY TO DYLINK. SET UP TO JOIN DYSET
/
DYLINK	0
	DZM	FA13	/THIS IS POSITIVE TO SHOW DYLINK
	LAC	DYLINK	/SET UP COMMON EXIT AND ARGUMENT POINTERS
	JMP	DYC
/
/  ENTRY TO DYSET
/
DYSET	0
	CMA!CLA		/SET MINUS TO SHOW DYSET
	DAC	FA13
	LAC	DYSET	/STRIP TOP BITS OFF DYSET
DYC	DAC	DYLINK	/KEEP FULL PC IN DYLINK FOR EXIT+ERROR MSG.
	AND	(77777	/AND STRIPPED ONE
	DAC	DYSET	/IN DYSET FOR ARGUMENT HANDLING
L76	LAW	0	/SET UP ENDDSP,ENDTXT BOTH EQUAL TO START
	AND	DYSET	/KEEP ONLY BANK BITS
	TAD*	DYSET	/ADD IN JUMP OVER ARGUMENT LIST
	AND	(77777	/AND KILL JUMP OP CODE
	DAC	ENDDSP
	DAC	ENDTXT
	LAC	FA13	/SET UP LINK TO SHOW SET-LINK
	RAL
	CLA!IAC		/NOW SET UP TO LOOK FOR DISPLAY FILE-TEXT
/			/FILE BOUNDARY. ALSO TO PUT LOGICAL FILE
/			/NUMBERS IN IF WE ARE A DYSET
	DAC	BOTTOM	/INITIAL LOGICAL FILE NUMBER
	LAC	DYSET	/SET UP THE POINTER
	JMP	DBE	/ENTRY POINT FOR SCAN
DB4	LAC*	ARGP	/AC HAS ADDR (REL(P)) OF FILE TOP
	JMS	JUST
	DAC	TEMP	/OR ADDR OF -1 LITERAL
	LAC*	TEMP	/EITHER THE -1, OR CONTENTS OF FILE TOP
/			/WHICH CAN NT BE NEGATIVE AT ANY TIME
	SNA		/CONTENTS OF FILE TOP CANNOT BE 0!!!!!
	JMP	DYER	/ERROR, GO DO MESSAGE
	SPA		/SKIP IF A FILE
	JMP	DB10	/IT'S THE DELIMITER, EXIT FROM LOOP
	ISZ	TEMP	/MOVE POINTER TO FILE+1
	LAC	BOTTOM	/GET LOGICAL FILE NUMBER
	SZL		/SKIP IF DYLINK
	DAC*	TEMP	/DYSET LABELS THE FILE WITH ITS LOGICAL NUMBER
	ISZ	BOTTOM	/NEXT LOGICAL FILE NUMBER
	LAC	ARGP	/MOVE POINTER
DBE	IAC		/INITIAL ENTRY
	SAD	ENDTXT	/ARE WE THRU LIST (NO -1)
	JMP	DB11	/YUUP
	DAC	ARGP	/UPDATED POINTER FOR NEXT FILE
	JMP	DB4
DB10	LAC	ARGP	/LEAVE ENDDSP POINTING TO -1 ARG.
	DAC	ENDDSP
DB11	JMS*	VTGL1	/GET BASE ADDR OF PARTITION
	DAC	BASE	/ROUTINE IN THE GRAPHICS PRIMITIVES RETURNS
/			/WITH THE DESIRED ADDRES IN AC
	JMS*	VTGL2	/GET LIGHT PEN ROUTINE ADDRESS
	DAC	LTP	/HERE AGAIN THE AC HAS THE RIGHT THING
	LAC	DYSET	/SET UP POINTER TO SCAN THRU DISPLAY FILES
/			/FOR MEMORY REFERENCES
	JMP	MAINE	/ENTER MAIN LOOP
/
/  MAIN LOOP
/
/  SET UP FOR A NEW FILE
/
MAINF	LAC	FA13	/PUT SET-LINK SWITCH INTO LINK
	RAL
	LAC	FILE	/FILE TOP ADDR (REL(P))
	DAC	POINT	/FOR SCAN FOR MEMORY REFERENCES
	TAD	BASE	/MAKE ABSOLUTE 13 BIT FILES TOP
	AND	(17777	/TO BE ADDED(SUBTRACTED) TO INSTRUCTION
	DAC	TEMP	/SAVE POSITIVE FORM
	SZL		/SKIP IF DYLINK
	CMA!IAC		/DYSET WANTS THIS QUANTITY NEGATIVE
	DAC	FA13	/GOT IT
	LAC	TEMP	/BRING BACK POSITIVE TO CHECK 8K BOUNDARY
	TAD*	POINT	/NOW ADD FILE LENGTH IN FILE TOP LOCATION
	AND	L76	/THIS IS A LAW 0 LITERAL. IF A BIT CARRYS
	SZA		/WE HAVE STRADDLED AN 8K BOUNDARY
	JMP	EIGHT	/WE DID, WE LOSE. MESSAGE TO USER
	LAC	FILE	/FILE ADDR AGAIN (REL(P))
	TAD*	POINT	/ADD LENGTH TO GET BOTTOM POINTER
	DAC	BOTTOM	/PLACE END POINTER TO CONTROL SCAN THRU FILE
/			/LOOP IN CASE THE LAST INSTRUCTION OF THE
/			/FILE IS NOT THE EXPECTER JMP*!
	JMP	BSKP	/DIRTY. THIS MOVES POITER DOWN 2. THE FIRST
/			/TWO LOCATIONS OF THE DISPLAY FILE DO
/			/NOT CONTAIN ANY USEFULL INFORATION FOR
/			/THE PURPOSES OF THE SCAN.
/
/  NOW HERE IS THE INSTRUCTION SCANNING LOOP
/
/
MAINI	LAW	15000	/MAKE A MASK TO SEE IF INSTRUCTION DISPLAY
	AND*	POINT	/SKIP, WHETHER OR NOT MICROCODED WITH
	SAD	(DSKP	/ANYTHING ELSE
	JMP	BSKP	/GO TREAT DISPLAY SKIP
	AND	(740000	/MASK FOR COMPARING TO ORDINARY INSTRUCTIONS
	SAD	(DSAVR	/IS IT SAVE OR RESTORE
	JMP	BSAVR	/YUP, GO TREAT IT
	SAD	(DCHAR	/CHARACTER STRING INSTRUCTION?
	JMP	BCH	/YES, GO DO IT
	SAD	(DJMP	/DISPLAY JUMP? IN ALL THESE CASES
	JMP	BJMP	/THE INSTRUCTION CAN ALSO BE INDIRECT
	SAD	(DJMS	/SUBROUTINE CALL
	JMP	BJMS	/THAT'S ALL THE ONES TO CHECK FOR
EL	LAC	POINT	/MOVE POINTER, BUT FIRST
	SAD	BOTTOM	/DID WE JUST DO THE LAST INSTRUCTION
	JMP	MAINL	/YES. GO MOVE TO NEXT FILE
ELL	ISZ	POINT	/MOVE POINTER, ENTRY POINT FROM BSKP
	JMP	MAINI	/GO BACK TO LOOK AT NEXT INSTRUCTION IN
/			/DISPLAY FILE
/
MAINL	LAC	FILEP	/MOVE ON TO NEXT FILE
MAINE	IAC		/ENTRY FOR FIRST FILE
	SAD	ENDDSP	/DONE?
	JMP*	DYLINK	/YEAH!
	DAC	FILEP	/NOPE, NEW POINTER AND CONTINUE
	LAC*	FILEP	/GET REAL FILE ADDR
	JMS	JUST	/DIRTY, XTRA INDIRECTION?
	DAC	FILE	/FILE TOP ADDR
	JMP	MAINF	/TO SET UP THE NEW FILE
/
/  ROUTINE TO DO ADDITITION ON THE INSTRUCTION TO EITHER
/  RELOCATE OR LINK IT. THE ROUTINE LEAVE THE LINK 0 FOR DYLINK
/ AND THE LINK 1 FOR SYSET. THE ROUTINE DOES A SKIP RETURN IF
/ THE INSTRUCTION IN QUESTION WAS INDIRECT. THE ROUTINE
/ PLACES IN MEM A REL(P) POINTER TO THE ADDRESS THAT THE
/ INSTRUCTION REFERENCES.
/
ACTION	0
	LAC	FA13	/GET ABSOLUTE (+ OR-) FILE TOP
	SMA		/SKIP IF DYSET
	CLA		/DYLINK ALREADY HAS REL(F) ADDR
	TAD*	POINT	/NOW HAVE REL(F) ADDR
	AND	(17777	/REDUCE TO 13 BITS
	TAD	FILE	/MAKE A REL(P) ADDR FOR BOTHSO WE CAN
	DAC	MEM	/REFERENCE IT. THIS JOB DONE.
	LAC	FA13	/ADDING THIS TO INSTRUCTION DOES RELOC-LINK
	CLL		/SO THAT ADDITION CARRIES INTO LINK FOR DYSET.
/			/LEAVES LINK AS SET-LINK SWITCH
	TAD*	POINT	/FOR BOTH CASES
	DAC*	POINT	/PLACE INSTRUCTION BACK IN FILE
	AND	(20000	/LEAVE AC NON0 IF INDIRECT INSTRUCTION
	SZA		/SKIP IF DIRECT
	ISZ	ACTION	/MAKE SKIP RETURN FOR INDIRECT
	JMP*	ACTION	/EXIT
/
/
/  ACTION ROUTINES FOR INDIVIDUAL INSTRUCTIONS
/
BSKP	ISZ	POINT	/ONDISPLAY SKIP MOVE POINTER OVER NEXT
	JMP	ELL	/INSTRUCTION, AND CONTINUE
/
/  SAVE RESTORE
/
BSAVR	JMS	ACTION	/DO RELOCATION
	NOP		/INDIRECT BIT HERE DIFFERENTIATES SAVE-RESTORE
	DZM*	MEM	/ZERO OPERAND JUST INCASE
	JMP	EL	/LOOP END TO MOVE POINT
/
/  JUMP (INDIRECT)
/
BJMP	JMS	ACTION	/DO RELOCATION
	JMP	BJREG	/GO TO JUMP DIRECT
BJMPI	LAW	-2	/QUIT UNLESS DJMPI IS AT FILE+2, ASSUMED
/			/TO BE A BLANKED FILE, IN WHICH CASE THE
/			/COMPARE ON BOTTOM WILL STOP SCAN
	TAD	POINT	/IS POINTER-2=FILE?
	SAD	FILE	/IF YES, A BLANKED FILE
	JMP	EL	/CONTINUE AS USUAL
	JMP	MAINL	/OTHERWISE, MOVE TO NEXT FILE
BJREG	LAC	MEM	/TRICKY POINTER WANTS TO BE MOVED TO WHERE
	DAC	POINT	/JUMP POINTS, SO WE WON'T LOOK AT
/			/POTENTIAL NON-INSTRUCTIONS.
	JMP	MAINI	/POINTER IN NEW POSITION SO TO TOP OF LOOP.
/
/  CHARACTER INSTRUCTION (INDIRECT)
/
BCH	JMS	ACTION	/DO THE BASIC RELOCATIONS
	JMP	EL	/ON DIRECT INSTRUCTION, DONE
	SNL		/SKIP ON DYSET
	JMP	LTS	/LINK-TEXT-SCAN. PICK UP FILE FROM ARG LIST
STS	LAC	BASE	/SET-TEXT-SCAN. GET BASE OF PARTITION
	CMA!IAC		/NEGATIVE TO CONVERT (ABS) REFERENCE
/			/IN FILE TO REL(P) TO COMPARE ARG. LIST
	TAD*	MEM	/BOTH POINT TO FILE TOP, SO THAT'S OK
	DAC*	MEM	/GOOD PLACE AS ANY TO HOLD IT.
	LAC	ENDDSP	/SET UP POINTER TO START
	SAD	ENDTXT	/IF THESE TWO EQUAL, NO TEXT FILES PROVIDED!
	JMP	DYER	/ERROR EXIT
	JMP	STE	/JOIN LOOP IN MIDDLE
/
/  DYSET SCAN FOR MATCHING TEXT FILE
/
STLL	LAC*	ARGP	/GET FILE ADDRESS  (REL(P))
	JMS	JUST	/XTRA INDIRECT
	AND	(77777	/STRIP 100000 BIT FROM FILE ADDR. I GUESS
/			/IT'S SOME FORTRAN TYPE OF ARRAY BIT.
	SAD*	MEM	/IS IT ONE POINTED TO IN DISPLAY FILE
	JMP	STG	/GOT IT!
	LAC	ARGP	/MOVE UP POINTER
STE	IAC		/INITIAL ENTRY POINT
	SAD	ENDTXT	/ARE WE YET AT END
	JMP	DYER	/YES, THAT'S BAD, EXIT
	DAC	ARGP	/NOPE, PLACE POINTER AND KEEP GOING
	JMP	STLL
STG	LAC	ARGP	/LOGICAL FILE NUMBER IS MINUS POSITION IN
/			/LIST, WITH THE FIRST ONE -1.
	CMA!IAC
	TAD	ENDDSP	/AND THIS IS THAT NUMBER
	DAC*	MEM	/AND PLACE IN DISPLAY FILE FOR DYLINK
	JMP	EL	/REJOIN SCAN THRU FILE
/
/  DYLINK PICK UP TEXT FILE
/
LTS	LAC*	MEM	/SHOULD BE MINUS POSITION IN ARG. LIST
	SMA!CMA!IAC	/SKIP IF MINUS, MAKE PLUS
	JMP	DYER	/OOPS, NOT CORRECT
	TAD	ENDDSP	/MAKE POINTER TO CORRECT FILE
	DAC	TEMP	/ADDRESS HOLDER
	LAC*	TEMP	/ADDRESS OF FILE REL(P)
	JMS	JUST
	AND	(77777	/STRIP OFF FUNNY BITS FROM TOP
	TAD	BASE	/MAKE ABSOLUTE ADDRESS
	DAC*	MEM	/PLACE IN FILE FOR CHARS*.
	JMP	EL
/
/  DISPLAY SUBROUTINE CALL (INDIRECT)
/
BJMS	JMS	ACTION	/DO DIRECT RELOCATION
	JMP	EL	/ALL FOR DIRECT
	SNL		/SKIP ON DYSET
	JMP	LDS	/LINK-DISPLAY-SCAN. GO LINK  SUBROUTINE ADDR
SDS	LAC*	MEM	/DYSET-DISPLAY-SCAN. CHECK IF LIGHT PEN ENABLE
	SAD	LTP	/IF IT IS, THAT'S 0 LOGICAL FILE
	JMP	SDLTP	/GO DO IT
	CMA!IAC		/WE NOW HAVE -(ABSFILE+1)
	TAD	BASE	/NOW HAVE -(RELFILE+1)
	CMA		/NOW HAVE RELFILE  , THAT IS REL(P) FIRST LOC.
	DAC*	MEM	/SAVE THAT FOR COMPARISON ON ARG LIST
	LAC	DYSET	/SET UP POINTER FOR ARG SCAN
	JMP	SDE	/JOIN LOOP IN MIDDLE
/
/  DYSET SCAN FOR MATCHING DISPLAY FILE
/
SDL	LAC*	ARGP	/GET FILE ADDR  REL(P)
	JMS	JUST
	SAD*	MEM	/IS IT RIGHT ONE
	JMP	SDG	/YEAH, GO GET IT LOGICAL NUMBER
	LAC	ARGP	/MOVE ON TO NEXT FILE
SDE	IAC		/INITIAL ENTRY
	SAD	ENDDSP	/THRU
	JMP	DYER	/THAT'S NO GOOD, WE DIDN'T FIND IT
	DAC	ARGP	/PLACE POINTER AND CONTINUE
	JMP	SDL
SDLTP	DZM*	MEM	/PLACE LOGICAL NUMBER OF 0
	JMP	EL	/REJOIN LOOP
SDG	IAC		/FILE +1  REL(P)
	DAC	TEMP
	LAC*	TEMP	/THIS IS LOGICAL FILE NUMBER
	DAC*	MEM	/PLACE IN DISPLAY FILE
	JMP	EL	/REJOIN MAIN LOOP
/
/  DYLINK PICK UP DISPLAY FILE
/
LDS	LAC*	MEM	/GET LOGICAL FILE NUMBER
	SPA		/HAS TO BE POSITIVE
	JMP	DYER
	SNA		/NON-ZERO UNLESS LIGHT PEN ENABLE
	JMP	LDLTP	/THAT WAS IT, GO GET ADDRESS
	LAC	DYSET	/POINTER TO SCAN THRU FILES
	JMP	LDE	/JOIN LOOP IN MIDDLE
/
LDL	LAC*	ARGP	/FILE ADDRESS (REL(P))
	JMS	JUST
	IAC		/POINTER TO LOGICAL FILE NUMBER
	DAC	TEMP
	LAC*	TEMP	/GET NUMBER FOR MATCH CHECK
	SAD*	MEM	/REMEMBER STORED ON POINTED BY MEM
	JMP	LDG	/GOT IT
	LAC	ARGP	/MOVE TO NEXT
LDE	IAC
	SAD	ENDDSP	/OUT OF FILES?
	JMP	DYER	/YUP
	DAC	ARGP	/PLACE AND CONTINUE
	JMP	LDL
LDLTP	LAC	LTP	/LIGHT PEN ENABLE ADDRESS (ABS)
	JMP	LDB	/COMMON FINISH UP
LDG	LAC	TEMP	/FIE+1  REL(P)
	TAD	BASE	/MAKE ADDRESS ABSOLUTE FOR DISPLAY PROCESSOR
LDB	DAC*	MEM	/PLACE ADDR IN FILE
	JMP	EL
/
/  ERROR EXITS
DYER	LAW	-6	/ERROR CODE FOR DYSET-DYLINK
	SKP		/JOIN OTHER GUY
EIGHT	LAW	-4	/8K ERROR CODE
	CMA!IAC		/MAKE POSITIVE TO XR
	PAX
	LAC	DYLINK	/ADDR+1 OF CALLER
	JMS*	VTGL3	/CALL ROUTINE IN VPR WITH ADDR+1 IN AC
/			/AND ERROR CODE IN XR
/			/WE NEVER RETURN. JMS* RATHER THAN JMP*
/			/ARBITRARY
	.END
