.TITLE LIB_CMPC compare byte strings .IDENT /V01.00/ ;++LIBCMPC.MAR ; ; Facility: ; Fermilab Accelerator Control System (ACNET) General Routine ; ; Abstract: ; This module contains routines to allow High Level Languages access ; to the VAX CMPC3 and CMPC5 instructions in order to perform a ; byte array compare without conversion to a character string. ; ; Environment: ; Stored in FERMILIB.OLB library, linked into users' programs. ; ;-- ; ; Modification History: ; ; Author: A. Waller Creation date: 28-Jun-1983 ; ; V01.01 dd-mmm-yyyy INT comments ; .PAGE .SUBTITLE Declarations ; ; Include Files: ; ; NONE ; ; Library Macros: ; ; NONE ; ; 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_CMPC3 compare two byte arrays with no fill byte ;+0LIB_CMPC3 ; ; Functional Description: ; LIB_CMPC3 will compare two byte arrays until the given length is ; satisfied. This function uses the VAX-11 CMPC3 instruction. ; ; Calling Sequence: ; ret-status = LIB_CMPC3( length,array1,array2 ) ; ; Input Parameters: ; length - Address of the integer value containing the ; length of the byte arrays. ; array1 - Address of the first byte array to compare. ; array2 - Address of the second byte array to compare. ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; ret-status - Integer longword value following the convention of the ; STR$COMPARE routine in the Real Time Library. ; ret-status = -1 array1 < array2 ; ret-status = 0 array1 = array2 ; ret-status = 1 array1 > array2 ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; See output parameters. ; ; Side Effects: ;- ;+ LIB_CMPC3 ; LIB_CMPC3 will compare two byte arrays until the given length is ; satisfied. This function uses the VAX-11 CMPC3 instruction. ; ; ret-status.wlu.v = LIB_CMPC3( length.rwu.r,array1.rz.r,array2.rz.r ) ; ; ret-status The return status has the same meaning as the Real Time ; Library routine STR$COMPARE. This is an integer longword ; value: ; -1 array1 < array2 ; 0 array1 = array2 ; +1 array1 > array2 ; ; length Address of integer value containing the length of the ; two byte arrays to compare. ; ; array1 Address of first byte array to compare. ; ; array2 Address of second byte array to compare. ; ;- .ENTRY LIB_CMPC3,^M ; MOVZWL @4(AP),R0 ;GET LENGTH OF ARRAYS MOVL 8(AP),R1 ;ADDRESS OF FIRST ARRAY TO R1 MOVL 12(AP),R3 ;ADDRESS OF SECOND ARRAY TO R2 ; CMPC3 R0,(R1),(R3) ;DO THE COMPARE ; BLSS 5$ ;NOW RETURN STR$COMPARE TYPE STATUS BGTR 10$ RET 5$: MOVL #-1,R0 ;ARRAY1 < ARRAY2 RET 10$: MOVL #1,R0 ;ARRAY1 > ARRAY2 RET .PAGE .SUBTITLE LIB_CMPC5 compare two byte arrays with fill byte ;+0LIB_CMPC5 ; ; Functional Description: ; LIB_CMPC5 will compare two byte arrays until the given length is ; satisfied. If one of the two arrays is shorter than the other, ; the fill byte will be used compare against the longer array. ; This function uses the VAX-11 CMPC5 instruction. ; ; Calling Sequence: ; ret-status = LIB_CMPC5( array1_length,array1,fill,array2_len,array2 ) ; ; Input Parameters: ; array1_length - Address of the integer value containing the ; length of the first byte array. ; array1 - Address of the first byte array to compare. ; fill - Address of the byte value containing the filler value ; used for the continued compare in the event that ; one array is shorter than the other. ; array2_length - Address of the integer value containing the ; length of the second byte array. ; array2 - Address of the second byte array to compare. ; ; Implicit Inputs: ; NONE ; ; Output Parameters: ; ret-status - Integer longword value following the convention of the ; STR$COMPARE routine in the Real Time Library. ; ret-status = -1 array1 < array2 ; ret-status = 0 array1 = array2 ; ret-status = 1 array1 > array2 ; ; Implicit Outputs: ; NONE ; ; Condition Codes: ; See output parameters. ; ; Side Effects: ;- ;+ LIB_CMPC5 ; LIB_CMPC5 will compare two byte arrays until the given length is ; satisfied. If one of the two arrays is shorter than the other, ; the fill byte will be used compare against the longer array. ; This function uses the VAX-11 CMPC5 instruction. ; ; ret-status.wlu.v = LIB_CMPC3( array1_length.rwu.r,array1.rz.r, ; fill.rb.r, ; array2_length.rwu.r,array2.rz.r ) ; ; ret-status The return status has the same meaning as the Real Time ; Library routine STR$COMPARE. This is an integer longword ; value: ; -1 array1 < array2 ; 0 array1 = array2 ; +1 array1 > array2 ; ; array1_length Address of integer value containing the length of the ; first byte array to compare. ; ; array1 Address of first byte array to compare. ; ; fill Address of byte value containing the filler value used ; for the continued compare in the event that one array ; is shorter than the other. ; ; array2_length Address of integer value containing the length of the ; second byte array to compare. ; ; array2 Address of second byte array to compare. ; ;- .ENTRY LIB_CMPC5,^M ; MOVZWL @4(AP),R0 ;GET LENGTH OF FIRST ARRAY MOVZWL @16(AP),R2 ;AND LENGTH OF SECOND ARRAY ; MOVL 8(AP),R1 ;ADDRESS OF FIRST ARRAY TO R1 MOVL 20(AP),R3 ;ADDRESS OF SECOND ARRAY TO R2 ; MOVZBL @12(AP),R4 ;GET FILLER BYTE FOR COMPARES ; CMPC5 R0,(R1),R4,R2,(R3) ;DO THE COMPARE ; BLSS 5$ ;NOW RETURN STR$COMPARE TYPE STATUS BGTR 10$ RET 5$: MOVL #-1,R0 ;ARRAY1 < ARRAY2 RET 10$: MOVL #1,R0 ;ARRAY1 > ARRAY2 RET .END