1*ce099b40Smartin/* $NetBSD: scanc.S,v 1.9 2008/04/28 20:24:06 martin Exp $ */ 2aa9eacddScgd 3df9baf23Smycroft/*- 4df9baf23Smycroft * Copyright (c) 1998 The NetBSD Foundation, Inc. 5df9baf23Smycroft * All rights reserved. 6df9baf23Smycroft * 7df9baf23Smycroft * This code is derived from software contributed to The NetBSD Foundation 8df9baf23Smycroft * by Charles M. Hannum. 9afe588b9Smycroft * 10afe588b9Smycroft * Redistribution and use in source and binary forms, with or without 11afe588b9Smycroft * modification, are permitted provided that the following conditions 12afe588b9Smycroft * are met: 13afe588b9Smycroft * 1. Redistributions of source code must retain the above copyright 14afe588b9Smycroft * notice, this list of conditions and the following disclaimer. 15afe588b9Smycroft * 2. Redistributions in binary form must reproduce the above copyright 16afe588b9Smycroft * notice, this list of conditions and the following disclaimer in the 17afe588b9Smycroft * documentation and/or other materials provided with the distribution. 18afe588b9Smycroft * 19df9baf23Smycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20df9baf23Smycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21df9baf23Smycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22df9baf23Smycroft * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23df9baf23Smycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24df9baf23Smycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25df9baf23Smycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26df9baf23Smycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27df9baf23Smycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28df9baf23Smycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29df9baf23Smycroft * POSSIBILITY OF SUCH DAMAGE. 30afe588b9Smycroft */ 31afe588b9Smycroft 32ff171dfbSdrochner#include <machine/asm.h> 33afe588b9Smycroft 34afe588b9SmycroftENTRY(scanc) 35afe588b9Smycroft movl 4(%esp),%ecx 36afe588b9Smycroft testl %ecx,%ecx 37afe588b9Smycroft jz 3f 38afe588b9Smycroft pushl %esi 392f681356Smycroft pushl %edi 40afe588b9Smycroft movl 16(%esp),%esi 412f681356Smycroft movl 20(%esp),%edi 42afe588b9Smycroft movb 24(%esp),%dl 432f681356Smycroft xorl %eax,%eax 44afe588b9Smycroft cld 45afe588b9Smycroft1: 46afe588b9Smycroft lodsb 472f681356Smycroft testb %dl,(%eax,%edi) 48fcb12cd7Smycroft jnz 2f 49fcb12cd7Smycroft decl %ecx 50fcb12cd7Smycroft jnz 1b 51afe588b9Smycroft2: 522f681356Smycroft popl %edi 53afe588b9Smycroft popl %esi 54afe588b9Smycroft3: 55afe588b9Smycroft movl %ecx,%eax 56afe588b9Smycroft ret 57