Subject: libkern/ffs.S
To: None <port-macppc@netbsd.org>
From: Martin J. Laubach <mjl@emsi.priv.at>
List: port-macppc
Date: 10/31/2001 01:31:42
  So I'm trying to get aquainted with the PPC processor, and as
a warm-up I've writting an assembler libkern/ffs.S which seems
to work fine (running with it for two months now).

  Nevertheless, could someone proficient with PPC look at the
snippet and yell if there's something terribly wrong in it? Not
that there's much that can go wrong in 6 instructions, but perhaps
stilistic changes are necessary before adding it to the tree?

  Thanks,

	mjl


--- snip ---
#include <machine/asm.h>

.align 4
ENTRY(ffs)
        neg     r4,r3
        and     r3,r4,r3
        cntlzw  r3,r3
        li      r0,32
        subf    r3,r3,r0
        blr