memcmp.s revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 2N/A * memcmp(s1, s2, len) 2N/A * Compare n bytes: s1>s2: >0 s1==s2: 0 s1<s2: <0 2N/A * Fast assembler language version of the following C-program for memcmp 2N/A * which represents the `standard' for the C-library. 2N/A * memcmp(const void *s1, const void *s2, size_t n) 2N/A * if (s1 != s2 && n != 0) { 2N/A * const char *ps1 = s1; 2N/A * const char *ps2 = s2; 2N/A * if (*ps1++ != *ps2++) 2N/A * return(ps1[-1] - ps2[-1]); 2N/A * } while (--n != 0); 2N/A sub %o4, %o5, %o0 ! return(*s1 - *s2) 2N/A ! double word compare - using ldd and faligndata. Compares upto 2N/A ! 8 byte multiple count and does byte compare for the residual. 2N/A prefetch [%o0 + (2 * BLOCK_SIZE)], #one_read 2N/A prefetch [%o1 + (2 * BLOCK_SIZE)], #one_read 2N/A ! if fprs.fef == 0, set it. Checking it, reqires 2 instructions. 2N/A ! So set it anyway, without checking. 2N/A rd %fprs, %o3 ! o3 = fprs 2N/A wr %g0, 0x4, %fprs ! fprs.fef = 1 2N/A andn %o2, 7, %o4 ! o4 has 8 byte aligned cnt 2N/A alignaddr %o1, %g0, %g1 2N/A prefetch [%g1 + (3 * BLOCK_SIZE)], #one_read 2N/A prefetch [%o0 + (3 * BLOCK_SIZE)], #one_read 2N/A faligndata %d0, %d2, %d8 2N/A fcmpne32 %d6, %d8, %o5