Author: Tord Romstad
Date: 04:31:48 04/16/04
Go up one level in this thread
On April 16, 2004 at 04:18:07, Gerd Isenberg wrote: >On April 16, 2004 at 03:22:55, Tony Werten wrote: > >>On April 16, 2004 at 02:48:28, Tord Romstad wrote: >> >>>On April 15, 2004 at 17:47:40, Sune Fischer wrote: >>> >>>>On April 15, 2004 at 15:40:30, Gerd Isenberg wrote: >>>> >>>>>>But since the relation between bb and 0x88 is: >>>>>>0x88 = bb shl 1-(bb and 7), you can also use it for bb. >>>>>> >>>>>>Tony >>>>> >>>>>Nice trick to save the additional and of the rank ;-) >>>> >>>>Same trick, only on the upper 3 bits: >>>>0x88 = bb + (bb & ~7) >>> >>>I use the following two macros: >>> >>>#define Expand(x) (((x)<<1)-((x)&7)) >>>#define Compress(x) (((x)&7)|(((x)&120)>>1)) >>> >>>The Expand() macro is, as far as I can see, identical to Tony's suggestion. >>>But is there a better way to write the Compress() macro? My solution looks >>>quite complicated, and it is hard to believe that it is optimal. >> >>bb = (x88+(x88 and 15)) shr 1 >> >>Tony >> > >Sune's expand to 0x88 only needs two instructions, because ~7 is a compile time >constant. But for Compress there seems no way to get rid of the third >"expensive" shift or div 2 ;-) > >x88 = bb + (bb&~7); >bb = (x88 + (x88&7)) >> 1; Cool. With the help of you, Sune, and Tony, my Expand() and Compress() macros are now both a tiny bit faster than before. Thanks to all of you! Tord
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.