Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: assembly--not really that fast

Author: Gunnar Andersson

Date: 14:32:09 01/13/02

Go up one level in this thread


On January 13, 2002 at 16:27:01, Tom Kerrigan wrote:

>On January 13, 2002 at 10:22:52, Robert Hyatt wrote:
>
>>1.  You know more about the program than the compiler.  No bounds-checking
>>on "switch" type statements is necessary.
>
>What bounds checking or "switch type statements" are going on in a C program if
>you don't explicitly put them in?

The compiler produces tests for if the default case (if any) applies or if no
case at all applies.  Try writing a large dense switch.  E.g. GCC compiles this
into a jump table *and* a couple of bounds checking statements.

>>3.  you know whether a value can exceed (say) 127 or not.  The compiler can't.
>
>Again, why does this matter?

You can keep it in e.g. al if you want to.  I think this is a minor issue
though.

>>4.  You know how many registers the CPU has and can design code around that,
>>while C doesn't give you such control.
>
>You can change the C until it produces the assembly that you want.

Nope.  Consider e.g. the FirstBit() function discussed in another recent thread.
 How do you write it in C so that a compiler finds the BSF hack?

>>5.  you know exactly which registers procedure "x" will destroy, so you don't
>>have to save everything before calling it.  If you are careful, you don't have
>>to save _anything_.
>
>The really strict calling conventions that you're thinking of here are no longer
>present in today's compilers.

But what registers to push and pop is still a relevant question.

/ Gunnar




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.