/339 DISPLAY - FORTRAN CALLABLE SUBPROGRAM PACKAGE
/DISPLAY FILE RELOCATION ROUTINES
/COPYRIGHT 1969, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/CALLING SEQUENCE:
/	1) TO MAKE DISPLAY FILES LOCATION INDEPENDENT:
/		JMS	DYSET
/		JMP	2*N+.+1
/		.DSA	PNAME1	/FIRST LOCATION OF A DISPLAY FILE.
/		.DSA	ASCII1	/POINTER TO 9-CHAR ASCII NAME
/		...
/		.DSA	PNAMEN	/UNLIMITED NUMBER OF PAIRS OF
/		.DSA	ASCIIN	/DISPLAY FILE - ASCII NAME
/
/	2) TO LINK DISPLAY FILES TO REAL CORE LOCATIONS:
/		JMS	DYLINK
/		JMP	2*N+.+1
/		.DSA	PNAME1
/		.DSA	ASCII1
/		...
/		.DSA	PNAMEN
/		.DSA	ASCIIN
/
/339 COMMANDS
PJMP=2010				/SUBPICTURE CALL
POP=3000				/SUBPICTURE RETURN
	.GLOBL	DYSET,DYLINK
/SUBROUTINE DYSET
DYSET	XX
	LAC	DYL34		/SET SWITCH TO SHOW DYSET ENTRY
	DAC	DYS24
/SET UP POINTERS TO START AND END OF ARGUMENT LIST.
	LAC	DYSET		/GET A POINTER TO THE ARGUMENT LIST.
DYS05	DAC	ARGP
	LAC*	DYSET		/GET A POINTER (13 BIT) TO THE
	AND	(17777		/END OF THE ARGUMENT LIST.
	DAC	ARGEND
/ANY MORE ARGUMENTS?
DYS10	ISZ	ARGP		/POINT AT DISPLAY POINTER
	LAC	ARGP		/CHECK FOR ANY MORE ARGUMENTS.
	AND	(17777		/KEEP 13 BITS.
	SAD	ARGEND
	JMP*	DYSET		/NO MORE ARGUMENTS, RETURN.
/SET UP DISPLAY FILE POINTERS
	LAC*	ARGP
	JMS	INDRCT		/GET ACTUAL ARGUMENT POINTER.
	DAC	PNAME
	DAC	PNPTR		/POINTER TO THE DISPLAY FILE.
	LAC*	PNPTR		/GET DISPLAY LENGTH.
	TAD	PNPTR		/ADD LOCATION.
	DAC	EPTR		/POINTER TO END OF DISPLAY FILE.
	ISZ	ARGP		/POINT AT ASCII POINTER.
/FIND PJMP'S
DYS20	ISZ	PNPTR		/POINT AT NEXT DISPLAY COMMAND.
	LAC*	PNPTR		/GET IT.
	AND	(7770		/CLEAR OUT VARIABLE PART.
	SAD	(PJMP		/IF PJMP
	JMP	DYS30		/GO CHANGE OPERAND.
DYS22	LAC	PNPTR		/ELSE CHECK IF END OF
	SAD	EPTR		/DISPLAY IS REACHED.
DYS24	XX			/RECYCLE IF SET, SET PNAME IF LINK.
	JMP	DYS20		/NOT YET, RECYCLE.
/LOOK FOR PJMP OPERAND IN THE ARGUMENT LIST.
DYS30	LAC	DYSET		/SET UP AN ARGUMENT POINTER FOR
	DAC	ARGP2		/THIS PASS THRU THE ARGUMENT LIST.
	ISZ	PNPTR		/POINT AT OPERAND OF PJMP.
	LAC	DYS24		/WAS THIS A CALL TO DYSET
	SAD	DYL31		/OR
	JMP	DYL10		/DYLINK.
DYS32	ISZ	ARGP2		/POINT AT DISPLAY FILE PTR.
	LAC	ARGP2		/CHECK FOR END OF ARGUMENT LIST.
	AND	(17777
	SAD	ARGEND
	JMP	DYS20		/GO CHECK NEXT DISPLAY COMMAND.
	LAC*	ARGP2		/GET DISPLAY FILE PTR.
	JMS	INDRCT		/GET ACTUAL ARG POINTER.
	TAD	D.1		/POINT TO FIRST COMMAND.
	AND	(7777		/KEEP 12 BITS.
	DAC	TEMP
	ISZ	ARGP2		/POINT AT ASCII POINTER.
	LAC*	PNPTR		/GET PJMP OPERAND.
	AND	(7777		/KEEP 12 BITS.
	SAD	TEMP		/IF EQUAL TO ARGUMENT
	JMP	DYS40		/GO SET UP RELATIVE POINTER.
	JMP	DYS32		/ELSE RECYCLE.
/SEARCH THRU END OF DISPLAY FILE FOR ASCII SUBPICTURE NAMES.
DYS40	LAC	EPTR
	DAC	EPTR2		/PTR TO MOVE UP FROM END OF FILE.
DYS42	LAC*	EPTR2
	AND	(7777
	SAD	(POP		/CHECK FOR LAST DISPLAY COMMAND.
	JMP	DYS50		/GO INSERT ASCII IN DISPLAY FILE.
	LAC	EPTR2		/POINT TO START OF
	TAD	(-3		/4-WORD ASCII BLOCK.
	DAC	EPTR2
	JMS	COMPR		/COMPARE ASCII STRINGS.
	JMP	DYS44		/SAME.
	LAC	EPTR2		/DIFFERENT, MOVE POINTER ABOVE THIS
	TAD	(-1		/ASCII BLOCK.
	DAC	EPTR2
	JMP	DYS42		/RECYCLE.
/INSERT RELATIVE POINTER TO ASCII OPERAND OF PJMP
DYS44	LAC	PNAME		/SET UP POINTER TO ASCII STRING
	CMA; TAD (1			/RELATIVE TO THE BEGINNING
	TAD	EPTR2		/OF THIS DISPLAY FILE.
	DAC*	PNPTR		/INSERT AS OPERAND OF PJMP.
	JMP	DYS20		/RETURN FOR NEXT DISPLAY COMMAND.
/INSERT NEW ASCII BLOCK AT END OF DISPLAY FILE.
DYS50	LAC*	ARGP2		/GET PTR TO ASCII BLOCK POINTER.
	JMS	INDRCT		/CORRECT FOR INDIRECT CALL ARG.
	DAC	TEMP
	LAC*	TEMP		/POINT TO ACTUAL TEXT.
	DAC	TEMP
	LAW	-4		/4 WORDS INTO FILE
	DAC	CNTR
DYS52	ISZ	EPTR		/MOVE END PTR DOWN FOR ASCII.
	LAC*	TEMP		/GET ASCII.
	DAC*	EPTR		/INSERT IN FILE.
	ISZ	TEMP
	ISZ	CNTR		/DONE 4?
	JMP	DYS52		/NO, RECYCLE.
	LAC	EPTR		/SET UP POINTER
	TAD	(-3		/TO START OF NEW BLOCK.
	DAC	EPTR2
	LAC*	PNAME		/UPDATE FILE LENGTH.
	TAD	(4
	DAC*	PNAME
	JMP	DYS44		/GO SET PJMP OPERAND.
	.EJECT
/COMPARE ASCII STRINGS. AC=STRING IN DISPLAY FILE, ARGP2=POINTER IN ARG LIST.
COMPR	XX
	DAC	TEMP2		/SAVE PTR TO ASCII IN DISPLAY FILE
	LAC*	ARGP2		/GET A POINTER FROM THE ARGUMENT
	JMS	INDRCT
	DAC	TEMP		/LIST TO AN ASCII BLOCK POINTER.
	LAC*	TEMP		/POINT TO ACTUAL TEXT.
	DAC	TEMP
	LAW	-4		/4 WORD BLOCK.
	DAC	CNTR
COM10	LAC*	TEMP		/COMPARE A WORD OF ASCII.
	SAD*	TEMP2
	JMP	COM20		/SAME, SET UP FOR NEXT WORD.
	ISZ	COMPR
	JMP*	COMPR		/DIFFERNET, RETURN.
COM20	ISZ	TEMP		/NEXT WORD OF ARGUMENT ASCII.
	ISZ	TEMP2		/NEXT WORD OF DISPLAY FILE ASCII.
	ISZ	CNTR		/DONE 4 WORDS?
	JMP	COM10		/NO, RECYCLE
	JMP*	COMPR		/RETURN.
/
/GET ACTUAL ARGUMENT INTO AC IF GIVEN ARGUMENT (IN AC) WAS INDIRECT.
INDRCT	XX
	SMA			/INDIRECT IF MINUS.
	JMP*	INDRCT		/DIRECT,RETURN.
	DAC	TEMP		/SAVE INDIRECT POINTER.
	LAC*	TEMP		/GET ACTUAL POINTER.
	JMP*	INDRCT		/RETURN
	.EJECT
/SUBROUTINE DYLINK
DYLINK	XX
	LAC	DYL31		/SET UP BRANCH TO INDICATE DYLINK
	DAC	DYS24		/ENTRY.
	LAC	DYLINK		/SET UP COMMON EXIT.
	DAC	DYSET
	JMP	DYS05		/GO START.
/SEARCH ARGUMENT LIST FOR ASCII POINTED AT BY PJMP OPERAND.
DYL10	ISZ	ARGP2		/NEXT DISPLAY FILE.
	LAC	ARGP2		/CHECK FOR END OF ARGUMENT
	AND	(17777
	SAD	ARGEND		/LIST.
	JMP	DYS20
	ISZ	ARGP2		/NEXT ASCII POINTER IN ARG LIST.
	LAC*	PNPTR		/COMPUTE ABS PTR TO DISPLAY FILE
	TAD	PNAME		/ASCII FROM PJMP OPERAND.
	JMS	COMPR		/COMPARE ASCII STRINGS.
	JMP	DYL20		/SAME, GO SET UP PJMP OPERAND.
	JMP	DYL10		/DIFFERENT, RECYCLE.
/INSERT DISPLAY FILE LOCATION AS OPERAND OF PJMP.
DYL20	LAC	ARGP2		/MOVE ARGUMENT PTR BACK TO PNAME
	TAD	(-1		/CORRESPONDING TO THIS ASCII.
	DAC	TEMP
	LAC*	TEMP		/GET DISPLAY FILE POINTER.
	JMS	INDRCT		/GET ACTUAL ARG PTR.
	DAC	TEMP
	TAD	D.1		/POINT TO FIRST DISPLAY COMMAND.
	AND	(7777		/KEEP 12 BITS.
	DAC*	PNPTR		/INSERT AS PJMP OPERAND.
	LAC	PNPTR		/POINT BACK AT PJMP.
	TAD	(-1
	DAC	TEMP2
	LAC	TEMP		/GET DISPLAY FILE POINTER.
	RTL; RTL; RTL; RAL		/MOVE BITS 3-5 TO 15-17
	AND	(7
	TAD	(PJMP		/SET UP PJMP WITH PROPER
	DAC*	TEMP2		/BREAK FIELD DIGIT.
	JMP	DYS20		/NEXT DISPLAY COMMAND.
/FIND LAST DISPLAY COMMAND (POP) AND SET RELATIVE POINTER (FILE LENGTH) TO IT AT
/WORD 0, EXCLUDING ASCII BLOCKS AT END OF FILE.
DYL30	LAC*	EPTR		/GET LAST DISPLAY FILE WORD.
	AND	(7777
	SAD	(POP		/POP IS THE LAST DISPLAY COMMAND.
	JMP	DYL32		/GO SET UP POINTER.
	LAC	EPTR		/DECREMENT END POINTER.
	TAD	(-1
	DAC	EPTR
DYL31	JMP	DYL30		/GET NEXT.
DYL32	LAC	PNAME		/POINTS TO BEGINNING OF FILE.
	CMA			/SUBTRACT FROM
	TAD	(1
	TAD	EPTR		/END POINTER.
	DAC*	PNAME		/STORE RELATIVE POINTER.
DYL34	JMP	DYS10		/BACK FOR NEXT DISPLAY FILE.
/CONSTANT AND SO ON (USW.)
ARGP				/ARGUMENT LIST POINTERS
ARGP2
ARGEND
PNAME				/DISPLAY FILE POINTERS
PNPTR
EPTR
EPTR2
D.1	2			/DISTANCE FROM START OF FILE TO FIRST COMMAND.
TEMP				/TEMPORARY STORAGE
TEMP2
CNTR				/COUNTER
	.END
