Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Porting to linux and inline assembly with gcc

Author: Tom Likens

Date: 07:04:52 10/05/02

Go up one level in this thread


On October 05, 2002 at 00:53:39, Russell Reagan wrote:

Russell,

For a long time "Brennan's Guide to Inline Assembly" was one of the best
resources on the web to introduce neophytes to Linux inline assembly.

http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html

Recently, (over the last few years) IBM has produced a nice document
worth looking over.

http://www-106.ibm.com/developerworks/linux/library/l-ia.html

This two guides should get you going.  As for your second question, the
gcc manual has fairly extensive information on the optimizations.  If you're
running linux try:

info gcc

at the command line.  This should provide you with most of the information
that you will need.  One other item to mention, if you are using gcc 3.2 you
might want to look into the profiling optimizations.

regards,
--tom

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