.TITLE LIB_UNDESCR Return byte array address from descriptor .IDENT /V01.01/ ;++UNDESCR.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) General Routines ; ; Abstract: ; This function returns the address of a byte array from the input ; array or string descriptor. NOTE: the routine only works if the ; input is the address of a descriptor. ; ; Environment: ; Module stored in FERMILIB.OLB and linked in users' programs. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 20-Sep-82 ; ; V01.00 20-Sep-82 FJN Got from DECUS Spr'82 VAX SIG tape from the ; Institute for Cancer Research submission and ; editted to standard FERMILIB scheme ; V01.01 15-Apr-83 FJN Standardizing help comments ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; .NOCROSS $DSCDEF ;Define descriptor fields .CROSS ; ; Local Macros: ; ; NONE ; ; Equated Symbols: ; nargs = 0 ;Offset to number of arguments descr = 4 ;Offset to address of input descriptor length = 8 ;Offset to address of longword in ; which to return string/array length ; ; Program section for code ; .PSECT _LIB_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SUBTITLE Return pointer and length from array/string descriptor ;+0LIB_UNDESCR ; ; Functional Description: ; Return a byte array pointer and optional byte length from an array or ; string pointer. ; ; Calling Sequence: ; pointer = LIB_UNDESCR(descr [,length]) ; ; Input Parameters: ; descr - address of an array, string or varying string descriptor. ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; pointer - address of the byte array is returned in register R0. ; length - (optional) address of a longword in which the string or array ; length in bytes is to be returned. For varying strings, the ; current length is returned (not the maximum length). ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; This routine only works for array, string and varying string ; descriptors. Both static and dynamic string descriptors are ; recognized, however one must beware of the problem of extracting ; the string pointer and length from the dynamic string descriptor ; due to the very nature of the dynamic strings. ; ;- ;+ LIB_UNDESCR ; Function to return the address of the byte array from a descriptor. ; ; pointer.wa.v = LIB_UNDESCR( descr.rx.dx [,length.wl.r] ) ; ; pointer byte array address returned from the array or string ; descriptor (returned in register R0). Passed by value. ; ; descr array, string or varying string. Both static and ; dynamic strings are handled. Passed by descriptor. ; ; length (optional) longword in which the length of the string ; or array is returned. For varying strings, the current ; length is returned. Passed by reference. ;- .ENTRY LIB_UNDESCR,^M<> ; MOVL descr(AP),R1 ;Get descriptor address CMPB #2,(AP) ;Was length parameter supplied? BNEQ 20$ ;If neq, no length parameter TSTL length(AP) ;Length parameter defaulted? BEQL 20$ ;If so, treat as if no length parameter CMPB DSC$B_CLASS(R1),- #DSC$K_CLASS_VS ;Is it a varying string descriptor? BEQL 50$ ;If so, special handling for them CMPB DSC$B_CLASS(R1),- #DSC$K_CLASS_D ;Is it a dynamic string descriptor? BEQL 5$ ;If so, treat as string descriptor CMPB DSC$B_CLASS(R1),- #DSC$K_CLASS_S ;Is it a static string descriptor? BNEQ 10$ ;If not, treat as array descriptor 5$: MOVZWL DSC$W_LENGTH(R1),- @length(AP) ;Return string length from descriptor BRB 20$ ;Go to return pointer 10$: MOVL DSC$L_ARSIZE(R1),- @length(AP) ;Return array length from descriptor 20$: MOVL DSC$A_POINTER(R1),R0 ;Return byte array address CMPB DSC$B_CLASS(R1),- #DSC$K_CLASS_VS ;Was it a varying string descriptor? BNEQ 30$ ;If not, just return with pointer TSTW (R0)+ ;For varying strings, modify pointer ; to point to BODY (string text). 30$: RET ; ; Special processing for return length and pointer of varying string. ; 50$: MOVL DSC$A_POINTER(R1),R0 ;Get pointer to length and text MOVZWL (R0)+,@length(AP) ;Return current string length (CURLEN) RET ; and pointer to string text (BODY) .END