.TITLE LIB_LOCB Locate byte in an array of bytes .IDENT /V01.00/ ;++LIBLOCB.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) General Routines ; ; Abstract: ; Provide High Level Language access to the LOCC instruction (Locate ; Character) without requiring string descriptors to allow use on ; byte arrays rather than "character" strings in a simplier fashion. ; ; Environment: ; Module stored in FERMILIB.OLB and linked in users' programs. ; ;-- ; ; Modification History: ; ; Author: F. Nagy Creation date: 28-Sep-83 ; ; V01.00 28-Sep-83 FJN Created for use with VAX-11 C programs ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; ; NONE ; ; Local Macros: ; ; NONE ; ; Equated Symbols: ; schval = 4 ;Argument offset to search byte value len = 8 ;Argument offset to length of array array = 12 ;Argument offset to array address ; ; Program section for code ; .PSECT _LIB_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,NOWRT,RD .SHOW BINARY .PAGE .SUBTITLE LIB_LOCB Locate byte value in an array ;+0LIB_LOCB ; ; Functional Description: ; Search an array of bytes for a specified value using the LOCB ; instruction. ; ; Calling Sequence: ; index.wlu.v = LIB_LOCB( schval.rbu.r, len.rwu.r, array.rbu.ra ) ; ; Input Parameters: ; schval - single byte search value ; len - length of byte array (obviously in bytes) ; array - address of byte array to be searched ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; index - 0 is returned if search value not found, otherwise the position ; in the array relative to the first element (1 means the first ; element) is returned. ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; NONE ; ; Side Effects: ; NONE ;- ;+ LIB_LOCB ; Locate a byte value in an array of bytes (similar to LIB$LOCC except ; that the search value and array are specified by reference rather than ; by descriptor). ; ; index.wlu.v = LIB_LOCB( schval.rbu.r, len.rwu.r, array.rbu.ra ) ; ; index returns the index of the byte in the array (if found) or ; zero if search value is not found in the array. The index ; is relative to the beginning of the array, treating the ; first element as index 1. ; ; schval the byte-long search value passed by reference. ; ; len length of the array (count of bytes in it). Passed by ; reference. ; ; array the array of bytes to be searched, passed by reference. ;- .ENTRY LIB_LOCB,^M<> LOCC @schval(AP),@len(AP),@array(AP) BEQL 9$ ;If value not found, return 0 in R0 SUBL3 array(AP),R1,R0 ;Gets offset to located byte INCL R0 ;Turn offset into return "index" 9$: RET .END