Author: Landon Rabern
Date: 12:07:41 01/25/01
Go up one level in this thread
On January 25, 2001 at 08:10:37, Uri Blass wrote:
>On January 24, 2001 at 23:08:47, Landon Rabern wrote:
>
>>On January 24, 2001 at 22:49:08, Landon Rabern wrote:
>>
>>>On January 24, 2001 at 03:43:03, Severi Salminen wrote:
>>>
>>>>>How much of a speed increase did you get from using MMX? I got only about a 35%
>>>>>increase.
>>>>
>>>>"Only"??? Are you mad :) 35% speedup from using different set of instructions is
>>>>_a lot_!! Are you now fast or were you slow back then?
>>>>
>>>>Severi
>>>
>>>I said only because I was under the impression that Larry was getting a lot
>>>faster, but I guess not.
>>>
>>>I was always pretty fast and now faster. Around 400,000 nps on a PIII-500 with
>>>my whole search and eval and everything on. My eval is not that complicated
>>>right now and could use some work and my move ordering can be improved some. I
>>>am at school now and do not have much time except to work on a Neural Network
>>>for my eval which I convinced them to give me credit for.
>>>
>>>The version of my program that is released 5.1 I think does not have the MMX
>>>stuff because I did not want to deal with making it compatible for above and
>>>below PII.
>>>
>>>Regards,
>>>
>>>Landon
>>
>>If anyone cares, here is the MMX code I wrote for it. I would not doubt it if
>>tehre were some good ways to optimize it.
>>
>>Regards,
>>
>>Landon
>>
>>#define gKnightMoves(fs) \
>>{ \
>> __asm mov eax,fs\
>> __asm shl eax,3\
>> __asm movq mm0,[knightMoves+eax] \
>> __asm pand mm0,notAllPieces \
>> __asm movq toMap,mm0 \
>>}
>>
>>#define gWhiteKnightCaps(fs) \
>>{ \
>> __asm mov eax,fs\
>> __asm shl eax,3\
>> __asm movq mm0,[knightMoves+eax] \
>> __asm pand mm0,blackPieces \
>> __asm movq toMap,mm0 \
>>}
>>
>>#define gBlackKnightCaps(fs) \
>>{ \
>> __asm mov eax,fs\
>> __asm shl eax,3\
>> __asm movq mm0,[knightMoves+eax] \
>> __asm pand mm0,whitePieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gKingMoves(fs) \
>>{ \
>> __asm mov eax,fs\
>> __asm shl eax,3\
>> __asm movq mm0,[kingMoves+eax] \
>> __asm pand mm0,notAllPieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gWhiteKingCaps(fs) \
>>{ \
>> __asm mov eax,fs\
>> __asm shl eax,3\
>> __asm movq mm0,[kingMoves+eax] \
>> __asm pand mm0,blackPieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gBlackKingCaps(fs) \
>>{ \
>> __asm mov eax,fs\
>> __asm shl eax,3\
>> __asm movq mm0,[kingMoves+eax] \
>> __asm pand mm0,whitePieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gWhitePawnMoves \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].whitePawns \
>> __asm psllq mm0,8\
>> __asm pand mm0,notAllPieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gBlackPawnMoves \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].blackPawns \
>> __asm psrlq mm0,8\
>> __asm pand mm0,notAllPieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gWhitePawnCapsLeft \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].whitePawns \
>> __asm pand mm0,zeroLeft\
>> __asm psllq mm0,9\
>> __asm pand mm0,blackPieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gBlackPawnCapsRight \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].blackPawns \
>> __asm pand mm0,zeroLeft\
>> __asm psrlq mm0,7\
>> __asm pand mm0,whitePieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gWhitePawnCapsRight \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].whitePawns \
>> __asm pand mm0,zeroRight\
>> __asm psllq mm0,7\
>> __asm pand mm0,blackPieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gBlackPawnCapsLeft \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].blackPawns \
>> __asm pand mm0,zeroRight\
>> __asm psrlq mm0,9\
>> __asm pand mm0,whitePieces \
>> __asm movq toMap,mm0 \
>>}
>>#define gRookQueenMoves(fs) \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].rot90cClock\
>> __asm mov ebx,fs\
>> __asm shl ebx,2\
>> __asm movd mm1,[vertShift+ebx]\
>> __asm psrlq mm0,mm1\
>> __asm pand mm0,maskFF\
>> __asm movd mm2,[horizShift+ebx]\
>> __asm movq mm3,allPieces\
>> __asm psrlq mm3,mm2\
>> __asm pand mm3,maskFF\
>> __asm shl ebx,9\
>> __asm movd ecx,mm0\
>> __asm shl ecx,3\
>> __asm movq mm4,[rookMovesVert+ebx+ecx]\
>> __asm movd ecx,mm3\
>> __asm shl ecx,3\
>> __asm movq mm5,[rookMovesHoriz+ebx+ecx]\
>> __asm por mm4,mm5\
>> __asm movq toMap,mm4\
>>}
>>#define gWhiteRookQueenCaps(fs) \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].rot90cClock\
>> __asm mov ebx,fs\
>> __asm shl ebx,2\
>> __asm movd mm1,[vertShift+ebx]\
>> __asm psrlq mm0,mm1\
>> __asm pand mm0,maskFF\
>> __asm movd mm2,[horizShift+ebx]\
>> __asm movq mm3,allPieces\
>> __asm psrlq mm3,mm2\
>> __asm pand mm3,maskFF\
>> __asm shl ebx,9\
>> __asm movd ecx,mm0\
>> __asm shl ecx,3\
>> __asm movq mm4,[rookAttacksVert+ebx+ecx]\
>> __asm movd ecx,mm3\
>> __asm shl ecx,3\
>> __asm movq mm5,[rookAttacksHoriz+ebx+ecx]\
>> __asm por mm4,mm5\
>> __asm pand mm4,blackPieces\
>> __asm movq toMap,mm4\
>>}
>>#define gBlackRookQueenCaps(fs) \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].rot90cClock\
>> __asm mov ebx,fs\
>> __asm shl ebx,2\
>> __asm movd mm1,[vertShift+ebx]\
>> __asm psrlq mm0,mm1\
>> __asm pand mm0,maskFF\
>> __asm movd mm2,[horizShift+ebx]\
>> __asm movq mm3,allPieces\
>> __asm psrlq mm3,mm2\
>> __asm pand mm3,maskFF\
>> __asm shl ebx,9\
>> __asm movd ecx,mm0\
>> __asm shl ecx,3\
>> __asm movq mm4,[rookAttacksVert+ebx+ecx]\
>> __asm movd ecx,mm3\
>> __asm shl ecx,3\
>> __asm movq mm5,[rookAttacksHoriz+ebx+ecx]\
>> __asm por mm4,mm5\
>> __asm pand mm4,whitePieces\
>> __asm movq toMap,mm4\
>>}
>>
>>#define gBishopQueenMoves(fs) \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].A1H8board\
>> __asm mov ebx,fs\
>> __asm shl ebx,2\
>> __asm movd mm1,[A1H8shift+ebx]\
>> __asm psrlq mm0,mm1\
>> __asm pand mm0,[A1H8rotMask+ebx]\
>> __asm movd mm2,[A8H1shift+ebx]\
>> __asm movq mm3,[eax].A8H1board\
>> __asm psrlq mm3,mm2\
>> __asm pand mm3,[A8H1rotMask+ebx]\
>> __asm shl ebx,9\
>> __asm movd ecx,mm0\
>> __asm shl ecx,3\
>> __asm movq mm4,[movesA1H8+ebx+ecx]\
>> __asm movd ecx,mm3\
>> __asm shl ecx,3\
>> __asm movq mm5,[movesA8H1+ebx+ecx]\
>> __asm por mm4,mm5\
>> __asm movq toMap,mm4\
>>}
>>#define gWhiteBishopQueenCaps(fs) \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].A1H8board\
>> __asm mov ebx,fs\
>> __asm shl ebx,2\
>> __asm movd mm1,[A1H8shift+ebx]\
>> __asm psrlq mm0,mm1\
>> __asm pand mm0,[A1H8rotMask+ebx]\
>> __asm movd mm2,[A8H1shift+ebx]\
>> __asm movq mm3,[eax].A8H1board\
>> __asm psrlq mm3,mm2\
>> __asm pand mm3,[A8H1rotMask+ebx]\
>> __asm shl ebx,9\
>> __asm movd ecx,mm0\
>> __asm shl ecx,3\
>> __asm movq mm4,[attacksA1H8+ebx+ecx]\
>> __asm movd ecx,mm3\
>> __asm shl ecx,3\
>> __asm movq mm5,[attacksA8H1+ebx+ecx]\
>> __asm por mm4,mm5\
>> __asm pand mm4,blackPieces\
>> __asm movq toMap,mm4\
>>}
>>#define gBlackBishopQueenCaps(fs) \
>>{ \
>> __asm mov eax,board\
>> __asm movq mm0,[eax].A1H8board\
>> __asm mov ebx,fs\
>> __asm shl ebx,2\
>> __asm movd mm1,[A1H8shift+ebx]\
>> __asm psrlq mm0,mm1\
>> __asm pand mm0,[A1H8rotMask+ebx]\
>> __asm movd mm2,[A8H1shift+ebx]\
>> __asm movq mm3,[eax].A8H1board\
>> __asm psrlq mm3,mm2\
>> __asm pand mm3,[A8H1rotMask+ebx]\
>> __asm shl ebx,9\
>> __asm movd ecx,mm0\
>> __asm shl ecx,3\
>> __asm movq mm4,[attacksA1H8+ebx+ecx]\
>> __asm movd ecx,mm3\
>> __asm shl ecx,3\
>> __asm movq mm5,[attacksA8H1+ebx+ecx]\
>> __asm por mm4,mm5\
>> __asm pand mm4,whitePieces\
>> __asm movq toMap,mm4\
>>}
>
>I would like to understand these short procedures.
>Unfortunately I know nothing about assembler.
>
>Can you explain what is the meaning of mov,shl,movq and other commands or give a
>link that explains only the meaning of these commands?
>
>Uri
Let me explain this small one.
#define gKnightMoves(fs) \
{ __asm mov eax,fs\
__asm shl eax,3\
__asm movq mm0,[knightMoves+eax] \
__asm pand mm0,notAllPieces
__asm movq toMap,mm0 \
}
fs is passed in and is fromSquare, the square where the knight is. this is put
into the eax register and the shifted left be 3 bits which is the same as
multiplying by 8. This is needed since the knightMoves array holds 8 byte
integers, then I move knightMoves[fs] into the mm0 register and the and that
with a 8 byte int with all bits set where there are not pieces, then I move this
into the 8 byte int toMap.
This is run then I loop though and extract the bits one by one and add the moves
to my moveList.
Regards,
Landon
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.