.MCALL .MODULE .MODULE SCOMP,VERSION=03,COMMENT=,IDENT=NO,LIB=YES ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .SBTTL SCOMP - FORTRAN CALLABLE SUBROUTINE ; ; CALL SCOMP(A,B,I) ; ; I = ISCOMP(A,B) ; ; THIS ROUTINE COMPARES THE STRINGS IN ARRAYS A AND B, AND SETS ; THE VALUE OF INTEGER VARIABLE I ACCORDINGLY: ; ; IF A < B THEN I < 0 ; IF A = B THEN I = 0 ; IF A > B THEN I > 0 ; ; IN ADDITION, WHEN A IS NOT EQUAL TO B, THE ABSOLUTE VALUE OF THE ; VARIABLE I IS SET TO THE CHARACTER POSITION OF THE FIRST INEQUALITY ; FOUND IN SCANNING. THE STRINGS ARE COMPARED LEFT-TO-RIGHT, ONE ; CHARACTER AT A TIME USING THE ASCII CODES FOR THE CHARACTERS. IF ; THE STRINGS A AND B ARE NOT OF THE SAME LENGTH, THEN THE SHORTER ; ONE IS TREATED AS IF IT WERE PADDED ON THE RIGHT WITH ENOUGH BLANKS ; TO MAKE THE TWO LENGTHS EQUAL. NEITHER STRING IS CHANGED BY THIS ; ROUTINE. A NULL STRING ARGUMENT IS EQUIVALENT TO A STRING CONTAINING ; ANY NUMBER OF BLANKS. ; ; MAS .PSECT SYS$I .GLOBL $SYSLB SCOMP:: ISCOMP::MOV (R5)+,R3 ;# OF ARGS IN LOW BYTE MOV (R5)+,R1 ;POINTER TO 1ST STRING (A) MOV (R5)+,R2 ;POINTER TO 2ND STRING (B) CLR R0 ;CHARACTER POSITION 1$: INC R0 ;COUNT TSTB @R1 ;AT END OF 1ST STRING? BEQ 5$ ;YES TSTB @R2 ;AT END OF 2ND STRING? BEQ 7$ ;YES CMPB (R1)+,(R2)+ ;COMPARE 2 CHARACTERS 2$: BEQ 1$ ;BRANCH IF EQUAL SO FAR BGT 3$ ;BRANCH IF A > B NEG R0 ;RETURN NEGATIVE (A < B) 3$: CMPB #3,R3 ;ARGUMENT I GIVEN? BHI 4$ ;NO, JUST RETURN VALUE IN R0 MOV R0,@(R5)+ ;STORE RESULT INTO I 4$: RETURN 5$: TSTB @R2 ;AT END OF BOTH STRINGS? BEQ 6$ ;YES, RETURN EQUAL INDICATION CMPB #40,(R2)+ ;ASSUME A PADDED WITH BLANKS BR 2$ ;JUMP TO NORMAL COMPARISON 6$: CLR R0 ;RETURN EQUAL INDICATOR BR 3$ 7$: CMPB (R1)+,#40 ;ASSUME B PADDED WITH BLANKS BR 2$ ;TO NORMAL COMPARISON .END