1*a30f7a9eSkettenis/* $OpenBSD: ffs.S,v 1.9 2018/01/21 21:56:02 kettenis Exp $ */ 2d987040fSdrahn/* $NetBSD: ffs.S,v 1.5 2003/04/05 23:08:52 bjh21 Exp $ */ 3d987040fSdrahn/* 4d987040fSdrahn * Copyright (c) 2001 Christopher Gilbert 5d987040fSdrahn * All rights reserved. 6d987040fSdrahn * 7d987040fSdrahn * Redistribution and use in source and binary forms, with or without 8d987040fSdrahn * modification, are permitted provided that the following conditions 9d987040fSdrahn * are met: 10d987040fSdrahn * 1. Redistributions of source code must retain the above copyright 11d987040fSdrahn * notice, this list of conditions and the following disclaimer. 12d987040fSdrahn * 2. Redistributions in binary form must reproduce the above copyright 13d987040fSdrahn * notice, this list of conditions and the following disclaimer in the 14d987040fSdrahn * documentation and/or other materials provided with the distribution. 15d987040fSdrahn * 3. The name of the company nor the name of the author may be used to 16d987040fSdrahn * endorse or promote products derived from this software without specific 17d987040fSdrahn * prior written permission. 18d987040fSdrahn * 19d987040fSdrahn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20d987040fSdrahn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21d987040fSdrahn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22d987040fSdrahn * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23d987040fSdrahn * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24d987040fSdrahn * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25d987040fSdrahn * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26d987040fSdrahn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27d987040fSdrahn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28d987040fSdrahn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29d987040fSdrahn * SUCH DAMAGE. 30d987040fSdrahn */ 31d987040fSdrahn 3238848718Sguenther#include "DEFS.h" 33d987040fSdrahn 34d987040fSdrahnENTRY(ffs) 35d987040fSdrahn /* Standard trick to isolate bottom bit in r0 or 0 if r0 = 0 on entry */ 36d987040fSdrahn rsb r1, r0, #0 37d987040fSdrahn ands r0, r0, r1 38*a30f7a9eSkettenis clzne r0, r0 39*a30f7a9eSkettenis rsbne r0, r0, #32 40*a30f7a9eSkettenis bx lr 41ae3cb403SguentherEND(ffs) 42ae3cb403Sguenther.protected ffs 43