ALWAYS 31JAN4 REVERSE .MCALL DIR$,CALLR ;************************************************************************ ;* * ;* MODULE: REVERSE - REVERSE A SPECIFIED RANGE OF VIRTUAL MEMORY * ;* IN PLACE * ;* * ;* AUTHOR: Chris Doran, Sira Ltd * ;* * ;* DATE: 31-JAN-84 * ;* * ;* 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 * ;* * ;************************************************************************ REVERSE:: CALL FROMTH ; Collect FROM/THRU/STEP/COUNT arguments BCS 250$ ; CS: FAILED ROR %3 ; Halve count w/o sign extend (cc from FROMTH) BEQ 250$ ; Nothing to do if count was 1 ADD #MEMORY,%1 ; Set pointers to real addresses: bottom (FROM) ADD #MEMORY,%2 ; and top (THRU) ; Swap %3=COUNT/2 bytes, decrementing top pointer and incrementing bottom. 10$: MOVB @R1,%4 ; Get byte from bottom address MOVB @%2,@%1 ; Copy in byte from top MOVB %4,@%2 ; Complete exchange ADD STEP,%1 ; Increment bottom location SUB STEP,%2 ; Decrement top location SOB %3,10$ ; Let's do it again 250$: CLC ; Normal exit = success 255$: ; ERROR EXIT CALLR EXTRA ; PURGE EXTRA & RETURN .END