Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about changing my data structure

Author: Gerd Isenberg

Date: 03:34:52 07/17/03

Go up one level in this thread


On July 17, 2003 at 06:14:04, Richard Pijl wrote:

>On July 17, 2003 at 05:58:39, Gerd Isenberg wrote:
>
>>On July 17, 2003 at 05:06:16, Uri Blass wrote:
>>
>>>Note that the name of the arrays that I have is different but I replaced the
>>>names to make it easy to understand the problem.
>>>
>>>I have an array A[64][8]
>>>
>>>I want to replace it by 8 arrays A0[64],A1[64],...A7[64] when A[i][j]=Aj[i]
>>
>>Hi Uri,
>>
>>I would suggest A[8][64] for your purpose.
>>
>>Then you still may index the arrays with A[j][sq] and you get your suggested
>>single 64 element arrays: A0[sq], A1[sq] with A[0][sq], A[1][sq] ...
>>
>>Gerd
>
>Of course! Let the compiler do the optimizing. I guess most compilers will
>recognize this?
>Richard.
>

Hi Richard,

there is nothing to optimize - only constant address calculation.
Even in debug-Version the compiler should generate assembler like this:

char i = A[0][sq]
; sq in ebx
movsx eax, byte ptr [_A + ebx]

char i = A[1][sq]
movsx eax, byte ptr [_A + 64 + ebx] ; _A + 64 is one constant

char i = A[j][sq]
; sq in ebx
; j in esi
shl   esi, 6 ; *64
movsx eax, byte ptr [_A + esi + ebx]

Cheers,
Gerd




This page took 0.42 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.