Knight capture code in Atlanchess. 
Moves are pushed onto the stack and retrieved at the end of the function.
Code: Select all
mov 	edi, dword ptr [boards+18h]	//white knights bitboard
		mov 	ebx, dword ptr [boards+1Ch]
		mov	eax, edi
		or 	eax, ebx
		je 	short capwBP1			//jump to bishops if no knights
		mov 	dword ptr [temp], edi		//save bitboard
		mov 	dword ptr [temp+4], ebx
	capwKN1:
		sub 	esi, esi
		bsr 	ecx, ebx			//bitscan
		lea	edx, [esi+1]
		jne 	short capwKN2
		bsr 	ecx, edi
		shl 	edx, cl
		xor 	esi, ecx
		xor 	dword ptr [temp], edx
		jmp 	short capwKN3
	capwKN2:
		shl 	edx, cl
		lea 	esi, [ecx+0x20]
		xor 	dword ptr [temp+4], edx
	capwKN3:
		mov 	edi, dword ptr Ndb [esi*8]	//knight moves database esi=FROM square
		mov 	ebx, dword ptr Ndb+4 [esi*8]
		and 	edi, dword ptr [boards+8]	//AND black pieces
		and 	ebx, dword ptr [boards+0Ch]
		mov	eax, edi
		or	eax, ebx
		je	short capwKN7			//loop if no moves
	capwKN4:
		mov	edx, 1
		bsr 	ecx, ebx			//bitscan
		jnz 	short capwKN5
		bsr 	ecx, edi
		shl 	edx, cl	
		xor 	edi, edx
		jmp	short capwKN6
	capwKN5:
		shl 	edx, cl
		lea 	ecx, [ecx+0x20]
		xor 	ebx, edx
	capwKN6:
		call	whiteCaps			//get captured piece and FROM in eax
		shl	ecx, 6
		mov	edx, ebx
		lea	eax, [eax+ecx+0x3000]		//ecx=TO square
		or 	edx, edi
		push	eax				//store move on stack
		jne 	short capwKN4			//loop if more moves
	capwKN7:
		mov 	edi, dword ptr [temp]
		mov 	ebx, dword ptr [temp+4]
		mov	eax, edi
		or	eax, ebx
		jne 	short capwKN1			//loop if more knights
Grant