	.TITLE   DOUBLE INTEGER ARITHMETIC PACKAGE FOR FORTRAN OTS
/ 
/ 
/                   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
/COPYRIGHT 1971, DIGITAL EQUIPMENT CORP., MAYNARD, MASS. 01754
/
/EDIT #007  7-14-71
/
	.DEFIN	GETARG,SUBR
	LAC*	SUBR
	ISZ	SUBR
	SMA!CLL
	JMP	.+3
	DAC	TEMP
	LAC*	TEMP	/SIGN BIT ON = ARG INDIRECT
	DAC	TEMP
	.ENDM
	.DEFIN	TAD1
	.IFDEF	%PDP9
	TAD	(1
	.ENDC
	.IFUND	%PDP9
	IAC
	.ENDC
	.ENDM
	.DEFIN	CIA
	.IFDEF	%PDP9
	CMA
	TAD	(1
	.ENDC
	.IFUND	%PDP9
	TCA
	.ENDC
	.ENDM
	.GLOBL	.JG,.JH,.JI,.JJ,.JK,.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