x86_string.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 FILE_LICENCE ( GPL2_OR_LATER );
00026
00027 #include <string.h>
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 void * __memcpy ( void *dest, const void *src, size_t len ) {
00038 void *edi = dest;
00039 const void *esi = src;
00040 int discard_ecx;
00041
00042
00043
00044
00045
00046 if ( len >> 2 ) {
00047 __asm__ __volatile__ ( "rep movsl"
00048 : "=&D" ( edi ), "=&S" ( esi ),
00049 "=&c" ( discard_ecx )
00050 : "0" ( edi ), "1" ( esi ),
00051 "2" ( len >> 2 )
00052 : "memory" );
00053 }
00054 if ( len & 0x02 ) {
00055 __asm__ __volatile__ ( "movsw" : "=&D" ( edi ), "=&S" ( esi )
00056 : "0" ( edi ), "1" ( esi ) : "memory" );
00057 }
00058 if ( len & 0x01 ) {
00059 __asm__ __volatile__ ( "movsb" : "=&D" ( edi ), "=&S" ( esi )
00060 : "0" ( edi ), "1" ( esi ) : "memory" );
00061 }
00062 return dest;
00063 }