.TITLE LIB_XNARGX Argument count for caller procedure .IDENT /V01.01/ ;++LIBXNARGX.MAR ; ; Facility: ; Fermilab Acclerator Control System - ACNET. ; General library routine. ; ; Abstract: ; Utility routine to return number of arguments to a subprogram ; for which zero or more procedure calls intervene before the ; utility routine is called. ; ; Environment: ; Called in user mode from a FORTRAN/PASCAL routine (usually). ; In FERMILIB.OLB object library. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 04-Oct-82 ; ; V01.00 04-Oct-82 FJN Created from ARGUTILS for use in support ; software packages ; V01.01 15-Apr-83 FJN Standardizing help comments ; .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_XNARGX Return number of arguments of a caller ;+ LIB_XNARGX ; Return the number of arguments passed to procedure in the current ; list of stack frames: ; ; number.wl.v = LIB_XNARGX([depth.rl.v]) ; ; number longword value with the number of arguments (0-255) in ; the argument list passed to the specified procedure. ; Passed by value. ; ; depth longword value indicating the depth in stack frames ; (outside the stack frame for LIB_XNARGX itself) to the ; calling procedure whose argument count is desired. ; Passed by value. ; ; If the depth is zero, then LIB_XNARGX(0) returns the same value ; as LIB_NARGS(), the number of arguments passed to the procedure ; which called LIB_XNARGX. If the depth is 1, then LIB_XNARGX(1) ; returns the number of arguments passed to the procedure which ; called the procedure which called LIB_XNARGX (caller of the ; caller of LIB_XNARGX), and so forth. No checks are made for ; exceeding current stack frame depth (probably result in an access ; violation). ; ;- ;+0LIB_XNARGX ; ; Functional Description: ; This routine returns the number of arguments in the call to the ; procedure called at a specified depth in the stack frames. ; ; Calling Sequence: ; number = LIB_XNARGX([depth]) ; ; Input Parameters: ; depth - stack depth of procedure whose argument count is desired ; as an immediate value longword argument. A depth of 0 ; corresponds to the caller of the LIB_XNARGX procedure. ; ; Implicit Inputs: ; Stack frame containing saved AP of caller. ; ; Output Parameters: ; R0 - number of arguments passed to specified calling procedure. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; Exceeding the stack frame depth will result in chaos. ; ;- .ENTRY LIB_XNARGX,^M<> MOVL FP,R0 ;Init to current stack frame (depth=0) TSTB (AP) ;Was depth argument given? BEQL 19$ ;No, default to depth of 0 MOVL 4(AP),R1 ;Yes, get stack frame depth BEQL 19$ ;If zero, pointer already setup 10$: MOVL SF$L_SAVE_FP(R0),R0 ;Get pointer to previous stack frame SOBGTR R1,10$ ;Loop until depth becomes 0 19$: MOVL @SF$L_SAVE_AP(R0),R0 ;Get number of arguments using old AP ; value of stack frame at depth RET .END