Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Various compiler questions

Author: Andrew Dados

Date: 14:45:32 01/14/02

Go up one level in this thread


On January 14, 2002 at 16:13:20, Robert Hyatt wrote:

>On January 14, 2002 at 15:32:19, Andrew Dados wrote:
>
>>
>>There is another technique requiring max k jumps, where 2^k>=number of switches
>>(minimum of k-1 jumps). It works with no jump table, but adding new cases is
>>tedious.
>>
>>e.g for 4 n values (1,30,120,500):
>>
>>if n>30 goto upper;
>>if n==1 {...; goto end;}
>> else {...; goto end;}  //n==30 here;
>>label upper:
>>if n==120 {...; goto end;}
>> else {...; goto end;}  //n==500 here;
>
>
>
>What if N=400???
>
>if n>30 is true, so we go to upper.
>
>n==120 is false so we do the else which is wrong...

I'll repeat:
******* Sure you may want to validate all cases btw... ********
:)


>
>Unless you are assuming that only the 4 values you gave are possible and
>you are binary-treeing the comparisons?  If so, that seems to be less
>useful as handling "default:" would be very messy, to say the least...

 Whole constract _could_ be controlled by compiler. Anyway I also doubt it has
any practical value.

>
>>
>>So you have max 2 jumps here, min one.
>>I doubt anyone would want to hand-code huge switch in such a way, but trick is
>>worth mentioning, imo.
>>
>>
>>-Andrew-
>>



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.