Created
March 30, 2012 06:14
-
-
Save eieio/2247390 to your computer and use it in GitHub Desktop.
Compact ARM bit count routine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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