From 643236347692ac7464f744020dea1c020c863110 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Wed, 25 Mar 2009 21:19:51 +0000 Subject: Fix MIPS FFS implementation git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20536 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/mips/ffs-mips.S | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/firmware/target/mips/ffs-mips.S b/firmware/target/mips/ffs-mips.S index f1547778d4..92f4e31729 100644 --- a/firmware/target/mips/ffs-mips.S +++ b/firmware/target/mips/ffs-mips.S @@ -40,11 +40,14 @@ .type find_first_set_bit, %function find_first_set_bit: - negu t0, a0 # t0 = a0 & -a0 - and t0, t0, a0 # - - clz v0, t0 # Get lead 0's count + beqz a0, 0 # if(a0 == 0) goto 1 + li v0, 32 # v0 = 32 + negu t0, a0 # t0 = -a0 + and t0, t0, a0 # t0 = a0 & t0 + clz v0, t0 # Get lead 0's count (v0=32 if all 0's) li t0, 31 # t0 = 31 - sub v0, t0, v0 # Return value = t0 - v0 - jr ra - nop + jr ra # + sub v0, t0, v0 # v0 = t0 - v0 +1: + jr ra # + nop # -- cgit v1.2.3