1/* 2 * Copyright (c) 1988 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 * advertising materials, and 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * This code is derived from software contributed to Berkeley by 18 * Computer Consoles Inc. 19 */ 20 21#if defined(LIBC_SCCS) && !defined(lint) 22 .asciz "@(#)memmove.s 5.1 (Berkeley) 05/15/90" 23#endif /* LIBC_SCCS and not lint */ 24 25/* void *memmove(to, from, size) */ 26#include "DEFS.h" 27 28ENTRY(memmove, 0) 29 movl 4(fp),r1 30 movl 8(fp),r0 31 movl 12(fp),r2 32 cmpl r0,r1 33 bgtru 1f /* normal forward case */ 34 beql 2f /* equal, nothing to do */ 35 addl2 r2,r0 /* may be overlapping */ 36 cmpl r0,r1 37 bgtru 3f 38 subl2 r2,r0 /* normal forward case */ 391: 40 movblk 412: 42 movl 4(fp),r0 /* this can probably be optimised */ 43 ret 443: 45 addl2 r2,r1 /* overlapping, must do backwards */ 46 subl3 r0,r1,r3 47 movl r2,r4 48 jbr 5f 494: 50 subl2 r3,r0 51 subl2 r3,r1 52 movl r3,r2 53 movblk 54 subl2 r3,r0 55 subl2 r3,r1 56 subl2 r3,r4 575: 58 cmpl r4,r3 59 jgtr 4b 60 movl r4,r2 61 subl2 r2,r0 62 subl2 r2,r1 63 movblk 64 movl 4(fp),r0 65 ret 66