Thread: asm bsf statement

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,743

    Question asm bsf statement

    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...
    My Website

    "Circular logic is good because it is."

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    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 -

    Code:
    #include <iostream> 
    
    using namespace std; 
    
    int main() 
    { 
    	int a = 4,b=0;
    	_asm {
    
    		bsf eax,a
    		mov b,eax
    	}
    
    	cout << b; 
    	return 0;
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  2. Understanding ASM
    By kuphryn in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 07-12-2002, 07:39 PM
  3. asm mov
    By manu in forum C++ Programming
    Replies: 1
    Last Post: 12-15-2001, 12:59 PM
  4. My graphics library
    By stupid_mutt in forum C Programming
    Replies: 3
    Last Post: 11-26-2001, 06:05 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM