Author: Flemming Rodler
Date: 13:09:43 04/20/00
Go up one level in this thread
>>PS: I still hope someone can show me how to inline assembler under gcc. > >Hopefully this helps (and works! :) : > >#define firstone(b) \ >({ int __value; long long int __arg = (b); \ > asm ("bsfl %1,%0\n\t" \ > "jnz 1f\n\t" \ > "bsfl 4+%1,%0\n\t"\ > "jz 2f\n\t" \ > "addl $32,%0\n\t" \ > "jmp 1f\n\t" \ > "2:\n\t" \ > "movl $64,%0\n\t" \ > "1:\n\t" \ > : "=r" (__value) \ > : "o" (__arg) ); \ > __value; }) > >best wishes, >Andrzej Nagorko Thanks. I just tried it out, and it seems to work fine. Nice that it returns 64 if there are no 1's in b. The execution time varies with the postion of the first 1. Not only depending in which half of the long long it resides in so the bsfl instruction have varying execution times. Maybe it a lookup table is faster? I will try later today. Thanks Flemming
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.