memcpy.s revision 9a70fc3be3b1e966bf78825cdb8d509963a6f0a1
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * CDDL HEADER START
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * The contents of this file are subject to the terms of the
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * Common Development and Distribution License (the "License").
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * You may not use this file except in compliance with the License.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * or http://www.opensolaris.org/os/licensing.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * See the License for the specific language governing permissions
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * and limitations under the License.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * When distributing Covered Code, include this CDDL HEADER in each
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * If applicable, add the following below this CDDL HEADER, with the
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * fields enclosed by brackets "[]" replaced with your own identifying
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * information: Portions Copyright [yyyy] [name of copyright owner]
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * CDDL HEADER END
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * Use is subject to license terms.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * memcpy(s1, s2, len)
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * Copy s2 to s1, always copy n bytes.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * Note: this C code does not work for overlapped copies.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * Memmove() and bcopy() do.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * Fast assembler language version of the following C-program for memcpy
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * which represents the `standard' for the C-library.
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * memcpy(void *s, const void *s0, size_t n)
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * if (n != 0) {
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * char *s1 = s;
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * const char *s2 = s0;
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * *s1++ = *s2++;
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * } while (--n != 0);
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne * return (s);
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne#define MED_WMAX 256 /* max copy for medium word-aligned case */
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne#define MED_MAX 256 /* max copy for medium longword-aligned case */
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne#define BSTORE_SIZE 256 /* min copy size for block store */
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne cmp %o1, %o0 ! if from address is >= to use forward copy
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne bgeu %ncc, .forcpy ! else use backward if ...
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne sub %o0, %o1, %o4 ! get difference of two addresses
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne cmp %o2, %o4 ! compare size and difference of addresses
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne bleu %ncc, .forcpy ! if size is bigger, do overlapped copy
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne ! an overlapped copy that must be done "backwards"
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne mov %o0, %g1 ! save dest address for return val
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne add %o1, %o2, %o1 ! get to end of source space
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne add %o0, %o2, %o0 ! get to end of destination space
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne ldub [%o1+2], %o3 ! load 2nd from last byte
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne stb %o3, [%o0-2] ! store 2nd from last byte
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne ldub [%o1+1], %o3 ! load 3rd from last byte
90549afd3fef439b4cc531dad6be941a1db2adb6Elizabeth Browne stb %o3, [%o0+1] ! store 3rd from last byte
.exit:
.dbalign:
.dbalign1:
.dbmed:
.dbmedl64:
.dbmedl32:
.dbmedl31:
nop !
.dbmedl15:
.dbbck:
.dbmv64:
.dbmv32:
.dbmvx:
.dbmv8:
.dbremain:
.dbbyte:
.dbexit:
.forcpy:
.medium:
.medw16:
.medw15:
nop !
nop !
.medwexit:
.medl32:
.medl31:
nop !
.medl15:
.medloop:
.large:
.xlarge: