ALWAYS 25JAN4 COPY .MCALL DIR$,CALLR ;************************************************************************ ;* * ;* MODULE: COPY - COPY A SPECIFIED RANGE OF VIRTUAL MEMORY * ;* * ;* AUTHOR: KEVIN ANGLEY * ;* * ;* DATE: 28-JUL-82 * ;* * ;* INPUT PARAMETERS: * ;* * ;* R0 POINTS TO THE COMMAND LINE IN PROCESS * ;* * ;* OUTPUT PARAMETERS: * ;* * ;* R0 POINTS JUST BEYOND THE LAST CHARACTER OF THE COPY * ;* * ;* DESTROYS: R1,R2,R3,R4,R5 * ;* * ;* * ;* REVISED BY: CHRIS DORAN, SIRA LTD * ;* * ;* DATE: 04-JAN-84 * ;* * ;* MODIFICATIONS: * ;* Support STEP option in FROM-THRU (includes ODD/EVEN * ;* option of 29AUG3 version, now generalised and done * ;* in FROMTH. * ;* Add REPEAT nnnn option to do multiple copies. * ;* * ;************************************************************************ COPY:: CALL FROMTH ; COLLECT FROM/THRU ARGUMENTS BCS 250$ ; CS: FAILED MOV R3,LENGTH ; Save count of bytes to move GETKEY TO ; GET KEYWORD TO BEQ 10$ ; EQ: GOT IT 5$: OUTPUT MSK ; MISSING KEYWORD BR 250$ ; TAKE ERROR EXIT 10$: CALL GETHXL ; GET TO ADDRESS BCS 250$ ; CS: FAILURE - TAKE ERROR EXIT MOV R1,R3 ; SET UP REGS FOR CALL TO VALID MOV R2,R4 MOV #1,RPTCNT ; Do it once by default TSTB @%0 ; End of line? BEQ 12$ ; Yes, keep default GETKEY REPEAT ; No, only allowed keyword is REPEAT BNE 5$ ; Error if it wasn't CALL GETHX4 ; Get a 4-byte repeat count BCS 250$ ; Give up if error MOV %1,RPTCNT ; Else we have a repeat count BEQ 250$ ; Do nothing (NOT 65536!) if 0 12$: PUSH R0 ; SAVE R0 15$: ; Come here to repeat whole block MOV FROM,R0 ; PUT FROM ADDR IN R0 ADD #MEMORY,R0 ; MAKE R0 POINT TO THE ACTUAL LOCATION MOV LENGTH,%5 ; Get length of block to copy 20$: CALL VALID ; VALIDATE TARGET ADDRESS BCS 240$ ; CS: INVALID - TAKE ERROR EXIT 30$: MOVB (R0),MEMORY(R2) ; COPY IT INC R2 ; INCREMENT AND UN-OFFSET TO POINTER CALL UNOFFST 40$: ; ALWAYS... ADD STEP,R0 ; INCREMENT FROM LOCATION SOB R5,20$ ; LET'S DO IT AGAIN DEC RPTCNT ; Any more REPEAT's? BNE 15$ ; Do it all again while there are CLC ; Normal exit = success 240$: POP R0 ; RESTORE R0 250$: ; ERROR EXIT CALLR EXTRA ; PURGE EXTRA & RETURN .PAGE .SBTTL COPY - DATA AREAS .PSECT PURE RO,D KEY REPEAT ; Only used here .EVEN .PSECT DATA RW,D LENGTH: .BLKW 1 ; Block length -- TO-FROM+STEP/STEP RPTCNT: .BLKW 1 ; Block repeat count .END