.TITLE LIB_ARGUTILS Subprogram argument list utilities .IDENT /V03.00/ ;++ARGUTILS.MAR ; ; Facility: ; Fermilab Acclerator Control System - ACNET. ; ; Abstract: ; Utility routines to return number of arguments in a subprogram ; call or to test for the existance of an argument. ; ; Environment: ; Called in user mode from a FORTRAN/PASCAL routine (usually). ; In FERMILIB.OLB object library. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 07-Jun-82 ; ; V02.00 08-Jun-82 FJN Changed names. ; V03.00 15-Apr-83 FJN Editted help comments and modified the ; LIB_NARGS routine to use an argument ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; .NOCROSS $SFDEF ;Stack frame offsets .CROSS ; ; Local Macros: ; ; NONE ; ; Equated Symbols: ; ; NONE ; ; Program section for code ; .PSECT _LIB_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SUBTITLE LIB_NARGS Return number of arguments of caller ;+ LIB_NARGS ; Return the number of arguments in the call to the outer (caller) ; procedure. ; ; number.wl.v = LIB_NARGS( [number.wl.r] ) ; ; number longword returning number of arguments (0-255) in ; the argument list passed to the outer procedure (the ; procedure in which LIB_NARGS is called). ; ; The result may be returned in the optional argument as well as via ; the function value. ;- ;+0LIB_NARGS ; ; Functional Description: ; This routine returns the number of arguments in the call to the ; caller of this routine. ; ; Calling Sequence: ; number = LIB_NARGS([number]) ; ; Input Parameters: ; NONE ; ; Implicit Inputs: ; Stack frame containing saved AP of caller. ; ; Output Parameters: ; R0 - number of arguments passed to caller of this routine. ; 4(AP) - address of an optional longword argument in which the ; same value as returned in R0 may also be returned. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; NONE ; ;- .ENTRY LIB_NARGS,^M<> MOVZBL @SF$L_SAVE_AP(FP),R0 ;Get number of arguments using old AP ; value (argument list to caller) TSTB (AP) ;Test for optional argument BEQL 9$ ;If no arguments, just leave now TSTL 4(AP) ;Check for address of longword BEQL 9$ ;If none, really is no argument MOVL R0,@4(AP) ;Return also via argument 9$: RET .PAGE .SUBTITLE LIB_TST_ARG_DFT Test for existant non-default argument ;+ LIB_TST_ARG_DFT ; Test that a specific argument in the argument list of the outer ; (caller of LIB_TST_ARG_DFT) procedure exists and is not defaulted. ; ; exists.wlu.v = LIB_TST_ARG_DFT( n.rbu.r ) ; ; n byte which contains the argument number to tested for. ; Passed by reference. ; ; exists longword value returned as -1 (TRUE) if the n'th argument ; is given in the outer procedure argument list and is not ; defaulted (argument value is non-zero). If n is greater ; than the number of arguments to the outer procedure or if ; the value of the n'th argument is zero, then 0 (FALSE) is ; returned. Passed by value. ; ;- ;+0LIB_TST_ARG_DFT ; ; Functional Description: ; This routine tests for a specific argument in the argument list of ; the caller of this routine. If the argument exists (argument number ; less than or equal to number of arguments in list) and is not defaulted ; (value of argument is non-zero), then TRUE is returned. ; ; Calling Sequence: ; exists = LIB_TST_ARG_DFT( n ) ; ; Input Parameters: ; 4(AP) - address of a byte giving the number of the argument to be ; tested. ; ; Implicit Inputs: ; Stack frame containing old AP (of caller) pointing to argument list ; to be tested. ; ; Output Parameters: ; R0 - TRUE (all 1's) returned if the argument exists and and was not ; defaulted (value is non-zero). FALSE (0) returned if the argument ; number is greater than the number of arguments in the argument ; list or if the argument value is zero (argument was defaulted). ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; NONE ; ;- .ENTRY LIB_TST_ARG_DFT,^M CLRL R0 ;Initialize to return FALSE MOVL SF$L_SAVE_AP(FP),R1 ;Get old AP MOVZBL @4(AP),R2 ;Get argument number for previous call CMPB R2,(R1) ;Compare against (old) number of args. BGTRU 9$ ;If >number arguments, return FALSE TSTL (R1)[R2] ;Check value of the (old) argument BEQL 9$ ;If =0 (default), return FALSE MCOML #0,R0 ;Return TRUE, arg n exists, not default 9$: RET .END