Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: a question for ed schröder

Author: Gerd Isenberg

Date: 10:58:45 04/10/04

Go up one level in this thread


On April 10, 2004 at 13:36:50, Anthony Cozzie wrote:

>On April 10, 2004 at 12:51:28, martin fierz wrote:
>
>>hi ed,
>>
>>you posted the stuff below a day or two ago, and i have a question about it:
>>
>>you suggest creating a "translation table" to get an unbroken and continuous
>>string of characters and then use this in a switch statement. if i understand
>>this right, i'd have to make a rather large first table which does something
>>like
>>
>>material-signature = function(pieces); somewhere in the 0...~4000 range (as far
>>as i can see, you need to be able to represent any combination of 1 vs 1 or
>>better 2 vs 2 pieces)
>>
>>X=conversiontable[material-signature] ~ somewhere in the 0...20 range for all
>>special cases you want to consider.
>>
>>then you do switch(X) - now how does the compiler know that the conversiontable
>>values are in a single range?? i don't understand how it can possibly know this
>>:-(
>>
>>cheers
>>  martin
>
>By default it simply bounds checks.
>
>e.g.:
>
>if(value < 0) jmp default;
>if(value > X) jmp default;
>jmp[table[value]];
>
>Or, you could always do the bounds check yourself (I think the compiler
>is smart about this):
>
>switch(a & 1023)
>{
>
>}
>
>Lastly, I believe there is a #pragma for most compilers that removes the bounds
>check.
>
>anthony

msc has assume keyword. If you put assume(0) in default case, bounds check is
disabled and an invalid case >= N or < 0 jumps to nirvana. Using bounds check
and default for most probable case(s) makes sense due to prediction issues with
indirect branches.

Gerd

<snip>



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.