ASMB,R,B,T,L
      HED ** MOVE CHARACTER ROUTINE - <MVC> **
      NAM UTIL,7
      ENT MVC,ICLC
      EXT GETCR,OUTCR,.ENTR
      COM X(4),Y(4),DUMMY(8),BUFFR(64)
      SPC 1
* <MVC> MOVES N CHARACTERS FROM A SOURCE STRING TO A DESTINATION
* STRING.  MOVING TAKES PLACE FROM LEFT TO RIGHT, AND OVER-
* LAPPING IS PERMITTED.
      SPC 1
* CALLING SEQUENCE - ASSEMBLY LANGUAGE:
      SPC 1
*     EXT MVC
*     JSB MVC
*     DEF *+6       RETURN ADDRESS
*     DEF ISORC     SOURCE STRING ADDRESS
*     DEF ISOF      SOURCE STRING OFFSET, IN CHARACTERS
*     DEF IDEST     DESTINATION STRING ADDRESS
*     DEF IDOF      DESTINATION STRING OFFSET
*     DEF LGTH      NUMBER OF CHARACTERS, 'N'.
      SPC 1
* CALLING SEQUENCE - FORTRAN:
      SPC 1
*     CALL MVC(ISORC,ISOF,IDEST,IDOF,LGTH)
      SPC 1
PARAM BSS 5         PARAMETER ADDRESS SAVE AREA
      SPC 1
MVC   NOP           ENTRY/EXIT POINT
      JSB .ENTR     PASS PARAMETER ADDRESSES
      DEF PARAM
      LDB *-1       PASS POINTER TO PARAMETER
      JSB INIT       LIST AND GO COMPUTE STRING
      BSS 0           PSUEDO ADDRESSES.
      LDA ZARA
      ALS
      STA TLOC+2    POST TEMPORARY STRING ADDR.
      LDA X+?LEN    SAVE X-STRING LGTH.
      STA TEMP1
      SPC 1
* MOVE THE SOURCE STRING TO A TEMPORARY STORAGE AREA, THUS
* PERMITTING STRING OVERLAP:
      SPC 1
MVC1  LDA XADDR     GET A SOURCE STRING CHARACTER
      JSB GETCR
      JMP MVC2      SOURCE STRING EXHAUSTED
      LDB A
      LDA TLOC
      JSB OUTCR     MOVE A CHARACTER TO TEMP.
      JMP MVC1
      SPC 1
* NOW MOVE THE TEMPORARY STRING (IN COMMON) TO THE DESTINATION
* STRING, THUS PERFORMING THE MOVE:
      SPC 1
MVC2  LDA TEMP1     GET LGTH(X)
      LDB ZARA
      BLS
      DST TLOC,I    POST LOCAL POINTER PAIR
      SPC 1
MVC3  LDA TLOC      GET A CHARACTER FROM T-STRING
      JSB GETCR
      JMP MVC,I     END OF STRING - RETURN
      LDB A
      LDA YADDR
      JSB OUTCR     POST IN DESTINATION SR.
      JMP MVC3
      HED ** COMPARE LOGICAL STRINGS - <ICLC> **
* <ICLC> COMPARES TWO STRINGS OF LENGTH 'N'.  COMPARISON
* PROCEEDS FROM LEFT TO RIGHT UNTIL A MISMATCH OCCURS, AT
* WHICH TIME A COMDITION CODE IS RETURNED IN (A).
      SPC 1
* CALLING SEQUENCE - ASSEMBLY LANGUAGE:
      SPC 1
*     EXT ICLC
*     JSB ICLC
*     DEF *+6
*     DEF ISORC
*     DEF ISOF
*     DEF ICOMP     COMPARISON STRING ADDRESS
*     DEF ICOF      COMPARISON STRING OFFSET (CHARS)
*     DEF LGTH      NUMBER OF CHARACTERS TO COMPARE
*     STA ICODE     CONDITION CODE RETURNED IN (A)
      SPC 1
* CALLING SEQUENCE - FORTRAN:
      SPC 1
*     ICODE=ICLC(ISORC,ISOF,ICOMP,ICOF,ILGTH)
      SPC 1
*     CONDITION CODE RETURNED (ICODE):
      SPC 1
*     ICODE=0       SOURCE STRING = COMPARISON STRING
*     ICODE>0       SOURCE STRING > COMPARISON STRING
*     ICODE<0       SOURCE STRING < COMPARISON STRING
      SPC 1
PARAS BSS 5         PARAMETER ADDRESS SAVE AREA
      SPC 1
ICLC  NOP          ENTRY/EXIT POINT
      JSB .ENTR     PASS PARAMETER ADDRESSES
      DEF PARAS
      LDB *-1
      JSB INIT
      SPC 1
ICLC1 LDA XADDR     FETCH SOURCE STRING CHAR.
      JSB GETCR
      JMP ICLC2     SOURCE STRING EXHAUSTED
      STA TEMP      SAVE IT
      LDA YADDR     FETCH COMPARISON STRING CHAR.
      JSB GETCR
      NOP
      CMA,INA
      ADA TEMP
      SZA,RSS       STRINGS EQUAL ?
      JMP ICLC1     YES - SO FAR - CONTINUE
      JMP ICLC,I    NO - RETURN CODE IN (A)
      SPC 1
ICLC2 CLA           RETURN CODE=0
      JMP ICLC,I
      SKP
* <INIT> INITIALIZATION ROUTINE - COMPUTES PSEUDO ADDRESSES.
      SPC 1
INIT  NOP
      STB TEMP
      LDA TEMP,I
      ALS
      ISZ TEMP
      LDB TEMP,I
      ADA B,I
      STA X+?ADR    POST X-ADDRESS
      ISZ TEMP
      SPC 1
      LDA TEMP,I
      ALS
      ISZ TEMP
      LDB TEMP,I
      ADA B,I
      STA Y+?ADR    POST Y-ADDRESS
      ISZ TEMP
      SPC 1
      LDA TEMP,I
      LDA A,I
      CMA
      STA X+?LEN    POST X-LGTH
      STA Y+?LEN
      JMP INIT,I
      SKP
* CONSTANTS, EQUATES, ETC.:
      SPC 1
A     EQU 0
B     EQU 1
?LEN  EQU 0
?ADR  EQU 1
TEMP1 NOP
TEMP  NOP
TLOC  DEF *+1
      BSS 2
ZARA  DEF BUFFR     ADDRESS OF TEMPORARY STRING
XADDR DEF X+?LEN
YADDR DEF Y+?LEN
      END
