1 /*
2 Copyright (c) 1990 The Regents of the University of California.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms are permitted
6 provided that the above copyright notice and this paragraph are
7 duplicated in all such forms and that any documentation,
8 and/or other materials related to such
9 distribution and use acknowledge that the software was developed
10 by the University of California, Berkeley.  The name of the
11 University may not be used to endorse or promote products derived
12 from this software without specific prior written permission.
13 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  */
17 /*
18  *  C library strcpy routine
19  *
20  *  This routine has been optimized for the CPU32+.
21  *  It should run on all 68k machines.
22  *
23  *  W. Eric Norum
24  *  Saskatchewan Accelerator Laboratory
25  *  University of Saskatchewan
26  *  Saskatoon, Saskatchewan, CANADA
27  *  eric@skatter.usask.ca
28  */
29 
30 #include <string.h>
31 
32 /*
33  * Copy bytes using CPU32+ loop mode if possible
34  */
35 
36 #undef strcpy
37 
38 char *
strcpy(char * to,const char * from)39 strcpy (char *to, const char *from)
40 {
41 	char *pto = to;
42 	unsigned int n = 0xFFFF;
43 
44 	__asm__ volatile ("1:\n"
45 	     "\tmove.b (%0)+,(%1)+\n"
46 #if defined(__mcpu32__)
47 	     "\tdbeq %2,1b\n"
48 #endif
49 	     "\tbne.b 1b\n" :
50 		"=a" (from), "=a" (pto), "=d" (n) :
51 		 "0" (from),  "1" (pto), "2" (n) :
52 		 "cc", "memory");
53 	return to;
54 }
55