View Full Version : asm bsf statement

05-27-2002, 12:54 PM
has anybody here used the assembly statement bsf?

I am looking at optimizing my gravity and collision detection code, and I was thinking of using bsf to loop through my variables and find the first set bit.

but then I tried using bsf in just a little sample piece of code and I could not get it to work using inline assembler. Has anybody in here used it before? I would like to see its usage in inline asm...

05-27-2002, 01:53 PM
No, but you may need to state the compiler you're using as they all seem to handle inline asm slightly differently. This works on MSVC -

#include <iostream>

using namespace std;

int main()
int a = 4,b=0;
_asm {

bsf eax,a
mov b,eax

cout << b;
return 0;