Author: Gerd Isenberg
Date: 09:22:21 09/15/02
Go up one level in this thread
The mmx-routine to get bishop-attacks is similar of course.
If you call it whith a set of two opposite colored bishops of one side, it's
easy to extract the single bishop attack bitboards by anding the combined with
the appropriate square color bitboards.
This feature is not so easy to implement with either rooks or queens. But even
with a combined rookattack board, it's also possible to gain some informations
about single rooks: anding the combined rook attacks with the rooks attacks from
one rook square on an otherwise empty board (determined by "Kogge-Stone parallel
prefix algorithm" or cheap table lookup), produces exactly the single rook
attack bitboard, if no other rook(s) shares the same file or rank. Otherwise it
includes all xray attacks through these rooks.
BitBoard getBishopAttacksMMX(BitBoard freeSquares, BitBoard bishops)
{
static const BitBoard eight = 8;
static const BitBoard notH = 0x7f7f7f7f7f7f7f7f;
__asm
{
movd mm6, [freeSquares]
punpckldq mm6, [freeSquares+4]
movd mm1, [bishops]
punpckldq mm1, [bishops+4] ; rightup
pxor mm0, mm0 ; bishopsAttacks := 0
movq mm5, [eight] ; saves some bytes in unrolled loop
movq mm7, [notH] ; saves some bytes in unrolled loop
movq mm2, mm1 ; leftup
movq mm3, mm1 ; rightdown
movq mm4, mm1 ; leftdown
// 1. diagonal fill in each direction
paddb mm1, mm1 ; right
psllq mm2, 7 ; leftup
paddb mm3, mm3 ; right
psllq mm1, mm5 ; rightup
pand mm2, mm7 ; clear left h-file wraps
por mm0, mm1 ; bishopsAttacks |= rightup
psrlq mm3, mm5 ; rightdown
pand mm1, mm6 ; clear rightup occupied
psrlq mm4, 9 ; leftdown
pand mm2, mm7 ; clear left h-file wraps
por mm0, mm3 ; bishopsAttacks |= rightdown
por mm0, mm4 ; bishopsAttacks |= leftdown
pand mm3, mm6 ; clear rightdown occupied
por mm0, mm2 ; bishopsAttacks |= leftup
pand mm4, mm6 ; clear leftdown occupied
pand mm2, mm6 ; clear leftup occupied
// 2. diagonal fill in each direction
// ....
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.