| View previous topic :: View next topic |
| Author |
Message |
Gerd Isenberg
Joined: 08 Mar 2006 Posts: 1785 Location: Hattingen, Germany
|
Post subject: Re: Two small in-register-lookups Posted: Tue Apr 24, 2007 10:58 am |
|
|
| jwes wrote: |
| Gerd Isenberg wrote: |
Color of square - assumes 32-bit shift by mod 32.
Is that portable for 32-bit ints?
(otherwise sq&31 or sq&15 is necessary)
| Code: |
unsigned int colorOfSquare (unsigned int sq) {
return (0xAA55AA55 >> sq) & 1;
}
|
|
or
| Code: |
unsigned int colorOfSquare (unsigned int sq) {
return ((sq>>3)^ sq) & 1;
}
|
|
Yes, I am aware of that. It has one dependent instruction more and with my mapping (a1 == 0, -> dark square), I even need one additional xor 1 or not
Thus loading the immediate constant to eax, plus shift, mask looks not that bad, despite variable shift needs cl.
| Code: |
; ecx == sq
mov eax, AA55AA55H
shr eax, cl
and eax, 1
|
|
|
| Back to top |
|
 |
|
| Subject |
Author |
Date/Time |
Two small in-register-lookups |
Gerd Isenberg |
Mon Apr 23, 2007 10:28 pm |
Re: Two small in-register-lookups |
J. Wesley Cleveland |
Tue Apr 24, 2007 9:08 am |
Re: Two small in-register-lookups |
H.G.Muller |
Tue Apr 24, 2007 9:51 am |
Re: Two small in-register-lookups |
Gerd Isenberg |
Tue Apr 24, 2007 11:00 am |
Re: Two small in-register-lookups |
Gerd Isenberg |
Tue Apr 24, 2007 10:58 am |
Re: Two small in-register-lookups |
H.G.Muller |
Tue Apr 24, 2007 12:37 pm |
Re: Two small in-register-lookups |
Gerd Isenberg |
Tue Apr 24, 2007 6:36 pm |
Re: Two small in-register-lookups |
Gerd Isenberg |
Tue Apr 24, 2007 8:11 pm |
Re: Two small in-register-lookups |
H.G.Muller |
Tue Apr 24, 2007 9:48 pm |
Re: Two small in-register-lookups |
Gerd Isenberg |
Tue Apr 24, 2007 9:57 pm |
Re: Two small in-register-lookups |
Tord Romstad |
Wed Apr 25, 2007 7:40 am |
Re: Two small in-register-lookups |
H.G.Muller |
Wed Apr 25, 2007 9:49 am |
Re: Two small in-register-lookups |
Tord Romstad |
Wed Apr 25, 2007 10:53 am |
Re: Two small in-register-lookups |
H.G.Muller |
Wed Apr 25, 2007 12:01 pm |
Re: Two small in-register-lookups |
Gerd Isenberg |
Fri Apr 27, 2007 7:41 pm |
Re: Two small in-register-lookups |
Gerd Isenberg |
Fri Apr 27, 2007 7:44 pm |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|