.TITLE STRCMP .IDENT /V01/ .ENABLE LC ; ; This module compares two ASCII strings and returns the offset of ; the first byte that is different. ; ; Author: V01 12-Jun-80 Phil Stephensen-Payne ; ; Calling Sequence: ; ; This subroutine is called via the standard FORTRAN calling sequence as: ; ; CALL STRCMP (STR1,STR2,LEN [,STATUS]) ; or ; STATUS = STRCMP (STR1,STR2,LEN) ; ; Where: ; STR1 = Address of first string ; STR2 = Address of second string ; LEN = Length to be compared ; STATUS = Optional error return ; ; Errors returned: ; ; STATUS = 0 if the comparison was successful ; = -1 if a parameter error was detected ; = offset of first byte that is different (1-LEN) ; ; External references: ; ; This module calls the subroutines PRMCHK ; ; ; STRCMP:: ; ; Specify number of parameters including error return. R5 not affected. ; MOV #4,R0 ; Check Number of Parameters CALL PRMCHK ; BCC 10$ ; If CC parameters OK - carry on JMP END ; Else error - exit immediately ; 10$: TST (R5)+ ; Ignore Number of parameters MOV (R5)+,R2 ; GET ADDRESS OF FIRST STRING MOV (R5)+,R1 ; GET ADDRESS OF SECOND STRING MOV @(R5)+,R0 ; GET LENGTH OF STRING BEQ END ; IF EQ ZERO - SAY THEY'RE EQUAL ; 20$: CMPB (R2)+,(R1)+ ; NEXT BYTE THE SAME ? BNE 30$ ; IF NE NO - THE SAME SOB R0,20$ ; CHECK EACH BYTE BR END ; EXIT OK ; 30$: NEG R0 ; CALCULATE BYTE NUMBER.. ADD @-2(R5),R0 ;.. OF FIRST DIFFERENT BYTE INC R0 ; ; END: RETURN .END