Skip to content

Instantly share code, notes, and snippets.

@eieio
Created March 30, 2012 06:14
Show Gist options
  • Save eieio/2247390 to your computer and use it in GitHub Desktop.
Save eieio/2247390 to your computer and use it in GitHub Desktop.
Compact ARM bit count routine
/*
* Compact ARM bitcount
* Copyright (c) 2012 Corey Tabaka
*/
#include <asm.h>
.text
.syntax unified
FUNCTION(bitcount)
movs r1, r0
beq 1f
mov r0, #0
0: add r0, r0, #1
sub r2, r1, #1
ands r1, r1, r2
bne 0b
1: bx lr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment