/FCOM FUNCTION FOR U/W-FOCAL:  JVZ

/THIS FUNCTION PROVIDES STORAGE AND RETRIEVAL OF VARIABLES
/IN FIELD 2 AND HENCE REQUIRES A 12K MACHINE.  THIS VER-
/SION DOES NOT PERFORM ANY ERROR CHECKING AND PRESUMES
/THAT THE ENTIRE FIELD IS AVAILABLE.  VARIABLES MAY BE
/STORED EITHER AS 4-WORD FLOATING POINT VALUES OR 2-WORD
/INTEGERS.  INTEGER STORAGE IS COMPATIBLE WITH THE KE-8E
/DOUBLE PRECISION EAE INSTRUCTIONS.

/TYPICAL CALLS:  S X=FCOM(N); S X=FCOM(N,Y); X FCOM(N,Z)
/RECURSIVE CALLS ARE ALLOWED: X FCOM(FCOM(-1,FCOM(-1)+1),Z)

/THE FIRST ARGUMENT IS THE INDEX (SUBSCRIPT) AND DETERMINES
/THE TYPE AND LOCATION OF STORAGE.  ONLY THE INTEGER PART
/OF THE INDEX WILL BE USED.  POSITIVE INDEX VALUES: 0,1,2..
/INDICATE FLOATING POINT (4-WORD) STORAGE, AND NEGATIVE
/VALUES SPECIFY INTEGER FORMAT (24-BIT).  CONVERSION FROM
/ONE TYPE TO THE OTHER IS AUTOMATIC.  WHEN ONLY THE
/INDEX IS GIVEN, 'FCOM' RETURNS THE VALUE OF THAT VARIABLE.
/IF A SECOND ARGUMENT IS GIVEN ITS VALUE WILL BE STORED
/AT THAT LOCATION & ALSO RETURNED AS THE FUNCTION VALUE.

/PROVIDING NO INTERVENING PROGRAMS USE FIELD 2, COMMON
/VARIABLES MAY BE STORED BY ONE FOCAL PROGRAM AND THEN USED
/LATER BY ANOTHER.  ADDITIONALLY THE APPROPRIATE AREA MAY
/BE SAVED VIA THE MONITOR 'SAVE' COMMAND AND LATER RELOADED
/WITH 'GET' BEFORE CALLING IN FOCAL.

/FOCAL SYMBOLS:

	FIELD 1

	AUTO=11
	EXP=44
	HORD=45
	LORD=46
	OVER2=47
	CHAR=66
	MCOM=72
	END=134
	EVAL=1613
	FNTABF=355
	FNEW=3224
	FIXIT=4453
	PUSHA=4542
	PUSHJ=4540
	POPA=4537
	RETURN=5536

	*END
	STVAR		/SYMBOL TABLE ORIGIN

	*FNTABF
	FCOM		/FUNCTION ENTRY POINT
	*FNEW		/ALSO FITS IN EAE HOLE AT 7250

FCOM,	FIXIT		/FIX INDEX AND SET EXP, OVER2
	PUSHA		/SAVE INDEX ON THE STACK
	TAD CHAR
	TAD MCOM
	SZA CLA		/CHECK FOR A SECOND ARGUMENT
	JMP FETCH
	PUSHJ		/BRING ARGUMENT INTO FLAC
	    EVAL-1	/(MAY BE AN EXPRESSION)
	JMS INDEX	/COMPUTE INDEX
	JMP .+7		/NEGATIVE INDEX

STORE,	TAD EXP		/FLOATING STORAGE
	DCA I AUTO
	TAD OVER2
	DCA I AUTO
	TAD LORD
	SKP
	FIXIT		/INTEGER STORAGE
	DCA I AUTO
	TAD HORD
	DCA I AUTO
	JMP INDEX-2	/FUNCTION RETURN

FETCH,	JMS INDEX	/COMPUTE INDEX
	JMP .+5		/NOTE: EXP=27, OVER2=0
	TAD I AUTO	/FLOATING RETRIEVAL
	DCA EXP
	TAD I AUTO
	DCA OVER2
	TAD I AUTO	/INTEGER RETRIEVAL
	DCA LORD
	TAD I AUTO
	DCA HORD
	CDF 10
	RETURN		/RETURN FLOATS INTEGERS

INDEX,	0		/COMPUTE INDEX AND BRANCH
	POPA		/EXAMINE ARGUMENT
	SPA		/FLOATING
	JMP .+4		/INTEGER
	ISZ INDEX	/SET POSITIVE RETURN
	CLL RTL		/MULTIPLY INDEX BY FOUR
	SKP
	CMA CLL RAL	/-(I+1)*2 FOR INTEGERS
	CIA		/SUBTRACT
	CMA		/ONE
	DCA AUTO	/LOAD INDEX REGISTER
	CDF 20		/COMMON STORAGE IN FIELD 2
	JMP I INDEX
STVAR=.
	$
