	.TITLE	ARGPROCS	ROUTINES TO EXAMINE ARGUMENT LISTS

;;
;	INTEGER FUNCTION NARGS()
;
;
;	Returns, as the function result, the number  of  actual  arguments
;	passed to the routine which called NARGS. Omitted actual arguments
;	[as in 'CALL X(A,,B)' ] are counted in this total.
;
;
;	Alan L. Zirkle     Naval Surface Weapons Center
;			   Code K105
;	28 Jun 1982	   Dahlgren, Virginia  22448
;

	.ENTRY	NARGS, ^M<>

	MOVZBL	@8(FP),R0	; 8(FP) IS CALLER'S AP

	RET

;;
;	LOGICAL FUNCTION ARG_EXIST(N)
;
;
;	Returns, as the function result, an indication of whether the  Nth
;	argument passed to the routine which called ARG_EXIST actually ex-
;	ists.   The Nth argument will not exist if N > the total number of
;	arguments passed or if the Nth argument was  omitted  [as  is  the
;	second  argument  in  'CALL X(A,,B)' ].   'N' is an integer in the
;	range (1,255).
;
;	NOTE--Character string arguments  to  FORTRAN  subprograms  cannot
;	      ever  be  omitted unless the corresponding dummy argument is
;	      either non-existent or not of  character  data  type.   This
;	      means  that  such  arguments can only be 'passed through' to
;	      another subprogram, as described  in  routine  'ARG_ADDRESS'
;	      below.
;
;
;	Alan L. Zirkle     Naval Surface Weapons Center
;			   Code K105
;	28 Jun 1982	   Dahlgren, Virginia  22448
;

	.ENTRY	ARG_EXIST, ^M<>

	MOVZBL	@4(AP),R0	; VALUE OF N IS NOW IN R0

	BEQL	FALSE		; ZERO IS NOT LEGAL VALUE FOR N

	CMPB	R0,@8(FP)	; 8(FP) IS CALLER'S AP

	BGTRU	FALSE		; BRANCH IF N > TOTAL NUMBER OF ACTUAL ARGS

	TSTL	@8(FP)[R0]	; TEST Nth ACTUAL ARGUMENT ADDRESS--IT WILL
				;  BE ZERO IF THE ARGUMENT DOESN'T EXIST
	BEQL	FALSE

	MOVL	#1,R0		; THE ARGUMENT DOES EXIST--RETURN .TRUE.

	RET

FALSE:	CLRL	R0		; THE ARGUMENT DOESN'T EXIST--RETURN .FALSE.

	RET

;;
;	INTEGER FUNCTION ARG_ADDRESS(N)
;
;
;	Returns, as the function result, the virtual address  of  the  Nth
;	argument  passed  to  the  routine which called ARG_ADDRESS.  This
;	address will be zero if N > the total number of  arguments  passed
;	or  if  the Nth argument was omitted [as is the second argument in
;	'CALL X(A,,B)' ].  'N' is an integer in the range (1,255).
;
;	NOTE--Character  string  arguments  to  FORTRAN subprograms cannot
;	      ever be omitted unless the corresponding dummy  argument  is
;	      either  non-existent  or  not  of character data type.  This
;	      means that such arguments can only  be  'passed  through' to
;	      another subprogram, by using the mechanism:
;
;			SUBROUTINE A
;			ADDR=ARG_ADDRESS(1)
;			IF (ADDR.NE.0) CALL B(%VAL(ADDR))
;
;	      (This does work for character constant  strings,  since  the
;	       FORTRAN  compiler  and the linker conspire to change actual
;	       character string arguments to  hollerith  when  the  formal
;	       argument  is  not of type CHARACTER.  This is documented in
;	       the FORTRAN manual.)
;
;
;	Alan L. Zirkle     Naval Surface Weapons Center
;			   Code K105
;	28 Jun 1982	   Dahlgren, Virginia  22448
;

	.ENTRY	ARG_ADDRESS, ^M<>

	MOVZBL	@4(AP),R0	; VALUE OF N IS NOW IN R0

	BEQL	BAD		; ZERO IS NOT LEGAL VALUE FOR N

	CMPB	R0,@8(FP)	; 8(FP) IS CALLER'S AP

	BGTRU	BAD		; BRANCH IF N > TOTAL NUMBER OF ACTUAL ARGS

	MOVL	@8(FP)[R0],R0	; GET Nth ACTUAL ARGUMENT ADDRESS--IT WILL
				;  BE ZERO IF THE ARGUMENT DOESN'T EXIST
	RET

BAD:	CLRL	R0		; THE ARGUMENT DOESN'T EXIST--RETURN ZERO

	RET

	.END
