Computer Chess Club Archives


Search

Terms

Messages

Subject: Porting to linux and inline assembly with gcc

Author: Russell Reagan

Date: 21:53:39 10/04/02


I have two questions. First...

I'm trying to get my program to compile under linux, but I'm stuck on the inline
assembly I use. Under VC++ I do:

int LowBit (Bitboard b) {
	_asm {
		mov	eax, -33
		bsf	eax, dword ptr [b+4]
		add	eax, 32
		bsf	eax, dword ptr [b]
	}
}

But I'm lost at how to make that work under gcc. I'm not exactly sure how gcc
handles inline assembly, and what the correct way to port this is. I think it
uses AT&T style assembly where the source and destination args are swapped, but
there are other things like the output, input, and clobbered register things
that you have to specify. I have no clue what to set those to.

Secondly, there seems to be quite a long list of compiler options for gcc. VC++
has always taken care of everything so I'm lost when it comes to compiling an
optimized program under linux. I know you use the -O, -O2, etc. options, but I
read all over about people using various options like -fomit-frame-pointer which
he says, "will make your code faster and smaller," but I have no idea why, and
it makes me wonder if this is a legitimate optimization, or if it's not going to
matter. It also makes me wonder how many other obscure options there are that
could cause speed ups. In VC++ there is a slew of command line options to the
compiler that are set for you, and you just pick "debug" mode compile or
"release", and release optimizes for you. Will I be ok if I just stick with -O2?

Thanks for your help.

Russell



This page took 0.01 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.