Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

memcpy.c

Go to the documentation of this file.
00001 
00006 /*
00007  *  The contents of this file are subject to the Mozilla Public License
00008  *  Version 1.0 (the "License"); you may not use this file except in
00009  *  compliance with the License. You may obtain a copy of the License at
00010  *  http://www.mozilla.org/MPL/
00011  *
00012  *  Software distributed under the License is distributed on an "AS IS"
00013  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
00014  *  License for the specific language governing rights and limitations
00015  *  under the License.
00016  *
00017  *  The Original Code is legOS code, released October 17, 1999.
00018  *
00019  *  The Initial Developer of the Original Code is Markus L. Noga.
00020  *  Portions created by Markus L. Noga are Copyright (C) 1999
00021  *  Markus L. Noga. All Rights Reserved.
00022  *
00023  *  Contributor(s): Markus L. Noga <markus@noga.de>
00024  */
00025 
00026 typedef unsigned        size_t;                 // data type for memory sizes
00027 
00028 
00030 //
00031 // Functions
00032 //
00034 
00036 
00043 void memcpy(void* dest,void* src,size_t size) {
00044     char *end=((char*)src)+size;
00045     int dummy;
00046 __asm__ __volatile__(
00047 #ifdef CONF_ROM_MEMCPY
00048         "\n\
00049 ; memcpy == [r1,r1+r2) -> [r0,r0+r2)\n\
00050 ; rom == [r0,r1) -> [r2,r2+r1-r0)\n\
00051         mov.w r0,r3\n\
00052         mov.w r1,r0\n\
00053         add.w r2,r1\n\
00054         mov.w r3,r2\n\
00055         jmp @rom_memcpy\n\
00056         "
00057 #else
00058         "\n\
00059          0:cmp %1,%2\n\
00060            beq 1f\n\
00061             mov.b @%1+,%0l\n\
00062             mov.b %0l,@%3\n\
00063             adds #1,%3\n\
00064            bra 0b\n\
00065          1:\n\
00066         "
00067 #endif
00068         : "=&r" (dummy)                         // output
00069         : "r" (src), "r" (end), "r" (dest)      // input
00070         : "cc","memory"                         // clobbered
00071         );
00072 }

Generated on Fri Feb 25 08:02:38 2005 for brickos by  doxygen 1.3.9.1