10Sstevel@tonic-gate/* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7298SMark.J.Nelson@Sun.COM * Common Development and Distribution License (the "License"). 6*7298SMark.J.Nelson@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate/* 220Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 26*7298SMark.J.Nelson@Sun.COM .file "memccpy.s" 270Sstevel@tonic-gate 280Sstevel@tonic-gate#include <sys/asm_linkage.h> 290Sstevel@tonic-gate 300Sstevel@tonic-gate ANSI_PRAGMA_WEAK(memccpy,function) 310Sstevel@tonic-gate 320Sstevel@tonic-gate#include "SYS.h" 330Sstevel@tonic-gate 340Sstevel@tonic-gate ENTRY(memccpy) 350Sstevel@tonic-gate pushl %esi / save register variable 360Sstevel@tonic-gate movl 8(%esp),%eax / %eax = address of dest string 370Sstevel@tonic-gate movl 12(%esp),%esi / %esi = address of source string 380Sstevel@tonic-gate movb 16(%esp),%dh / %dh = character to search for 390Sstevel@tonic-gate movl 20(%esp),%ecx / %ecx = length to go still 400Sstevel@tonic-gate.loop: 410Sstevel@tonic-gate decl %ecx / decrement bytes to go 420Sstevel@tonic-gate jl .notfound 430Sstevel@tonic-gate movb (%esi),%dl 440Sstevel@tonic-gate movb %dl,(%eax) / move byte 450Sstevel@tonic-gate cmpb %dh,%dl / is it the byte sought? 460Sstevel@tonic-gate je .found / yes 470Sstevel@tonic-gate 480Sstevel@tonic-gate decl %ecx / decrement bytes to go 490Sstevel@tonic-gate jl .notfound 500Sstevel@tonic-gate movb 1(%esi),%dl 510Sstevel@tonic-gate movb %dl,1(%eax) / move byte 520Sstevel@tonic-gate cmpb %dh,%dl / is it the byte sought? 530Sstevel@tonic-gate je .found1 / yes 540Sstevel@tonic-gate 550Sstevel@tonic-gate decl %ecx / decrement bytes to go 560Sstevel@tonic-gate jl .notfound 570Sstevel@tonic-gate movb 2(%esi),%dl 580Sstevel@tonic-gate movb %dl,2(%eax) / move byte 590Sstevel@tonic-gate cmpb %dh,%dl / is it the byte sought? 600Sstevel@tonic-gate je .found2 / yes 610Sstevel@tonic-gate 620Sstevel@tonic-gate decl %ecx / decrement bytes to go 630Sstevel@tonic-gate jl .notfound 640Sstevel@tonic-gate movb 3(%esi),%dl 650Sstevel@tonic-gate movb %dl,3(%eax) / move byte 660Sstevel@tonic-gate addl $4,%esi 670Sstevel@tonic-gate addl $4,%eax 680Sstevel@tonic-gate cmpb %dh,%dl / is it the byte sought? 690Sstevel@tonic-gate jne .loop / no 700Sstevel@tonic-gate decl %eax 710Sstevel@tonic-gate 720Sstevel@tonic-gate.found: 730Sstevel@tonic-gate popl %esi / restore register variable 740Sstevel@tonic-gate incl %eax / return pointer to next byte in dest 750Sstevel@tonic-gate ret 760Sstevel@tonic-gate 770Sstevel@tonic-gate .align 4 780Sstevel@tonic-gate.found2: 790Sstevel@tonic-gate incl %eax 800Sstevel@tonic-gate.found1: 810Sstevel@tonic-gate popl %esi / restore register variable 820Sstevel@tonic-gate addl $2,%eax / return pointer to next byte in dest 830Sstevel@tonic-gate ret 840Sstevel@tonic-gate 850Sstevel@tonic-gate .align 4 860Sstevel@tonic-gate.notfound: 870Sstevel@tonic-gate popl %esi / restore register variable 880Sstevel@tonic-gate xorl %eax,%eax / search fails 890Sstevel@tonic-gate ret 900Sstevel@tonic-gate SET_SIZE(memccpy) 91