/* 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 ___memmovePP; ___memmovePP: move_core: R2=PASS R12, R1=pma_i; /*Test for zero length*/ IF EQ JUMP (PC, restore_state) (DB); R0=PASS R4; R4=PASS R8; pm_to_pm_move: COMP(R4,R0), pma_i=R4; /*Test TO < FROM, oint to source*/ IF LT JUMP (PC, pm_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. */ pm_forward_copy:pm_ptr=R0; /*Point to sink*/ LCNTR=R2, DO pm_copy_fwrd UNTIL LCE; R2=PM(pma_i,1); pm_copy_fwrd: PM(pm_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. */ pm_backward_copy:R4=R4+R2; /*Find end of source array*/ R4=R4-1; R4=R0+R2, pma_i=R4; /*Find end of sink array*/ R4=R4-1; pm_ptr=R4; /*Point to end of sink*/ LCNTR=R2, DO pm_copy_bkrd UNTIL LCE; R2=PM(pma_i,-1); pm_copy_bkrd: PM(pm_ptr,-1)=R2; restore_state: FETCH_RETURN pma_i=R1; RETURN (DB); RESTORE_STACK RESTORE_FRAME .ENDSEG;