本帖最后由 uc_stm8 于 2011-7-14 14:23 编辑
8位BYTE节复制
void __memcpy_fast( uint8 * to, uint8 * from, size_t count)
{
if(count==0)
{
return ;
}
size_t n = (count + 7 ) / 8 ;
switch (count % 8 )
{
case 0 :
do { * to ++ = * from ++ ;
case 7 : * to ++ = * from ++ ;
case 6 : * to ++ = * from ++ ;
case 5 : * to ++ = * from ++ ;
case 4 : * to ++ = * from ++ ;
case 3 : * to ++ = * from ++ ;
case 2 : * to ++ = * from ++ ;
case 1 : * to ++ = * from ++ ;
} while ( -- n > 0 );
}
}
32位DWORD复制
void __memcpy_uint32_fast( uint32 * to, uint32 * from, size_t count)
{
if(count==0)
{
return ;
}
size_t n = (count + 7 ) / 8 ;
switch (count % 8 )
{
case 0 :
do { * to ++ = * from ++ ;
case 7 : * to ++ = * from ++ ;
case 6 : * to ++ = * from ++ ;
case 5 : * to ++ = * from ++ ;
case 4 : * to ++ = * from ++ ;
case 3 : * to ++ = * from ++ ;
case 2 : * to ++ = * from ++ ;
case 1 : * to ++ = * from ++ ;
} while ( -- n > 0 );
}
}
|