/* This C language subroutine copies range of memory into another without overlap problems. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 4/30/90 Updated on 5/94 by AS Updated on 2/95 by AS - separated polymorphic functions #include
void *memmove(void *s1, const void *s2, size_t size); */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; .GLOBAL _memmove; .GLOBAL ___memmoveDD; _memmove: ___memmoveDD: move_core: R2=PASS R12, R1=dma_i; /*Test for zero length*/ IF EQ JUMP (PC, restore_state) (DB); /*Jump to copy routine*/ R0=PASS R4; nop; dm_to_dm_move: COMP(R8,R0), dma_i=R8; /*Test TO < FROM, point to source*/ IF LT JUMP (PC, dm_backward_copy); /*copy from back to front*/ IF EQ JUMP (PC, restore_state); /*Same arrays!*/ /* The source array is higher in memory then the sink array. A normal copy will not corrupt the data. */ dm_forward_copy:dm_ptr=R0; /*Point to sink*/ LCNTR=R2, DO dm_copy_fwrd UNTIL LCE; R2=DM(dma_i,1); dm_copy_fwrd: DM(dm_ptr,1)=R2; JUMP (PC, restore_state); /* The source array is lower in memory then the sink array. A normal copy might corrupt the data. A copy from the back to the front will not corrupt the data. */ dm_backward_copy:R8=R8+R2; /*Find end of source array*/ R8=R8-1; R8=R0+R2, dma_i=R8; /*Find end of sink array*/ R8=R8-1; dm_ptr=R8; /*Point to end of sink*/ LCNTR=R2, DO dm_copy_bkrd UNTIL LCE; R2=DM(dma_i,-1); dm_copy_bkrd: DM(dm_ptr,-1)=R2; restore_state: FETCH_RETURN dma_i=R1; RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;