.TITLE STINSE .IDENT /V02/ .ENABLE LC ; ; This routine inserts one ASCII string before another one ; ; Author: V01 16-Mar-79 Mark Woolfson ; V02 28-Jan-80 Phil Stephensen-Payne ; ; Calling Sequence: ; ; This subroutine is called via the standard FORTRAN callin sequence as:- ; ; CALL STINSE(INSSTR,INSLEN,DESSTR,DESLEN [,STATUS]) ; or ; STATUS = STINSE(INSSTR,INSLEN,DESSTR,DESLEN) ; ; Where:- ; INSSTR = Address of the string to be inserted ; INSLEN = Length of string to be inserted ; DESSTR = Address at which string is to be inserted ; DESLEN = Length of original string after insertion point ; STATUS = Optional error return ; ; Errors Returned: ; STATUS = 0 if the operation was successful ; = -1 if a parameter error was detected ; ; External References: ; ; This module calls the subroutine PRMCHK ; ; ; STINSE:: MOV #5,R0 ;SET UP NUMBER OF PARAMS CALL PRMCHK ;CHECK ON PARAMETERS BCS 30$ ; If cs parameter error - exit MOVB @8.(R5),R2 ; Get length of original string BIC #177400,R2 ; Clear any sign extension MOV R2,R1 ; Save lenth for later ADD 6(R5),R2 ; Hence get address of end CLR R0 ; Initialise for success MOVB @4(R5), R4 ;GET LENGTH OF INSERTING STRING BIC #177400,R4 ; Clear sin extension BEQ 30$ ;QUIT IF NOTHING TO DO MOV R4,R3 ; Save lenth for later ADD R2, R4 ;CALC NEW END OF STRING TST R1 ; Anything to move? BEQ 15$ ; If eq no - omit move ; 10$: MOVB -(R2), -(R4) ;COPY BYTE SOB R1, 10$ ;TEST FOR END OF MOVE ; 15$: MOV 2(R5), R4 ;GET ADDR OF INS STRING ; 20$: MOVB (R4)+, (R2)+ ;MOVE BYTES SOB R3,20$ ;TEST OF END OF INSERT ; 30$: RETURN ;QUIT .END