PEXT question

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28461
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

PEXT question

Post by hgm »

Perhaps someone who has experience with the use of PEXT for bitboard move generation can help me with this:

How does the PEXT instruction behave if the mask has no set bits at all? Does it produce a zero result?

I run into this issue when preparing tables for generation of diagonal (as opposed to anti-diagonal) rides. E.g. on an 8x8 board the diagonal f1-h3 has only 3 squares, and a piece on g2 would only have unblockable leaps to f1 and h3. So the mask for this square would be zero. Would it cause any problems to treat that square the same as the others in a PEXT implementation? (With a 'table' of attacks bitboards containing only a single element, with moves to f1 and h3.)
User avatar
RubiChess
Posts: 660
Joined: Fri Mar 30, 2018 7:20 am
Full name: Andreas Matthies

Re: PEXT question

Post by RubiChess »

hgm wrote: Sat Jan 31, 2026 9:41 am How does the PEXT instruction behave if the mask has no set bits at all? Does it produce a zero result?
https://www.felixcloutier.com/x86/pext
mask == 0 => result = 0

Regards, Andreas
User avatar
hgm
Posts: 28461
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: PEXT question

Post by hgm »

Thanks! So nothing to worry about. :D