|
|
1.1 ! root 1: /*- ! 2: * Copyright (c) 1990 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * This code is derived from software contributed to Berkeley by ! 6: * the Systems Programming Group of the University of Utah Computer ! 7: * Science Department. ! 8: * ! 9: * Redistribution and use in source and binary forms are permitted ! 10: * provided that: (1) source distributions retain this entire copyright ! 11: * notice and comment, and (2) distributions including binaries display ! 12: * the following acknowledgement: ``This product includes software ! 13: * developed by the University of California, Berkeley and its contributors'' ! 14: * in the documentation or other materials provided with the distribution ! 15: * and in all advertising materials mentioning features or use of this ! 16: * software. Neither the name of the University nor the names of its ! 17: * contributors may be used to endorse or promote products derived ! 18: * from this software without specific prior written permission. ! 19: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 20: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 21: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 22: */ ! 23: ! 24: #if defined(LIBC_SCCS) && !defined(lint) ! 25: .asciz "@(#)bcopy.s 5.1 (Berkeley) 5/12/90" ! 26: #endif /* LIBC_SCCS and not lint */ ! 27: ! 28: #include "DEFS.h" ! 29: ! 30: /* ! 31: * This is probably not the best we can do, but it is still 2-10 times ! 32: * faster than the C version in the portable gen directory. ! 33: * ! 34: * Things that might help: ! 35: * - unroll the longword copy loop (might not be good for a 68020) ! 36: * - longword align when possible (only on the 68020) ! 37: * - use nested DBcc instructions or use one and limit size to 64K ! 38: */ ! 39: ENTRY(bcopy) ! 40: movl sp@(12),d1 /* check count */ ! 41: jle bcdone /* <= 0, don't do anything */ ! 42: movl sp@(4),a0 /* src address */ ! 43: movl sp@(8),a1 /* dest address */ ! 44: cmpl a1,a0 /* src after dest? */ ! 45: jlt bcback /* yes, must copy backwards */ ! 46: movl a0,d0 ! 47: btst #0,d0 /* src address odd? */ ! 48: jeq bcfeven /* no, skip alignment */ ! 49: movb a0@+,a1@+ /* yes, copy a byte */ ! 50: subql #1,d1 /* adjust count */ ! 51: jeq bcdone /* count 0, all done */ ! 52: bcfeven: ! 53: movl a1,d0 ! 54: btst #0,d0 /* dest address odd? */ ! 55: jne bcfbloop /* yes, no hope for alignment, copy bytes */ ! 56: movl d1,d0 /* no, both even */ ! 57: lsrl #2,d0 /* convert count to longword count */ ! 58: jeq bcfbloop /* count 0, skip longword loop */ ! 59: bcflloop: ! 60: movl a0@+,a1@+ /* copy a longword */ ! 61: subql #1,d0 /* adjust count */ ! 62: jne bcflloop /* still more, keep copying */ ! 63: andl #3,d1 /* what remains */ ! 64: jeq bcdone /* nothing, all done */ ! 65: bcfbloop: ! 66: movb a0@+,a1@+ /* copy a byte */ ! 67: subql #1,d1 /* adjust count */ ! 68: jne bcfbloop /* still more, keep going */ ! 69: bcdone: ! 70: rts ! 71: bcback: ! 72: addl d1,a0 /* src pointer to end */ ! 73: addl d1,a1 /* dest pointer to end */ ! 74: movl a0,d0 ! 75: btst #0,d0 /* src address odd? */ ! 76: jeq bcbeven /* no, skip alignment */ ! 77: movb a0@-,a1@- /* yes, copy a byte */ ! 78: subql #1,d1 /* adjust count */ ! 79: jeq bcdone /* count 0, all done */ ! 80: bcbeven: ! 81: movl a1,d0 ! 82: btst #0,d0 /* dest address odd? */ ! 83: jne bcbbloop /* yes, no hope for alignment, copy bytes */ ! 84: movl d1,d0 /* no, both even */ ! 85: lsrl #2,d0 /* convert count to longword count */ ! 86: jeq bcbbloop /* count 0, skip longword loop */ ! 87: bcblloop: ! 88: movl a0@-,a1@- /* copy a longword */ ! 89: subql #1,d0 /* adjust count */ ! 90: jne bcblloop /* still more, keep copying */ ! 91: andl #3,d1 /* what remains */ ! 92: jeq bcdone /* nothing, all done */ ! 93: bcbbloop: ! 94: movb a0@-,a1@- /* copy a byte */ ! 95: subql #1,d1 /* adjust count */ ! 96: jne bcbbloop /* still more, keep going */ ! 97: rts ! 98:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.