2010-05-17 18:44:26 +02:00
|
|
|
/* bsr64() - 64 bit bit scan reverse Author: Erik van der Kouwe */
|
|
|
|
/* 15 May 2010 */
|
|
|
|
#include <minix/compiler.h>
|
2010-08-17 18:44:07 +02:00
|
|
|
#include <machine/asm.h>
|
2010-05-17 18:44:26 +02:00
|
|
|
|
2010-08-17 18:44:07 +02:00
|
|
|
ENTRY(bsr64)
|
2010-05-17 18:44:26 +02:00
|
|
|
/* int bsr64(u64_t i); */
|
|
|
|
bsr 8(%esp), %eax /* check high-order DWORD */
|
|
|
|
jnz 0f /* non-zero: return index+32 */
|
|
|
|
bsr 4(%esp), %eax /* check low-order DWORD */
|
|
|
|
jnz 1f /* non-zero: return index */
|
|
|
|
movl $-1, %eax /* both were zero, return -1 */
|
|
|
|
jmp 1f
|
|
|
|
0: addl $32, %eax /* add 32 to high-order index */
|
|
|
|
1: ret
|