Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: curiosity killed the cat... hi/lo bit C verses Assembly

Author: Gerd Isenberg

Date: 00:22:21 07/18/03

Go up one level in this thread


I tried PPRO it on the fly, see yourself:



PUBLIC	?leastSigBit64@@YAH_K@Z				; leastSigBit64
; Function compile flags: /Ogtay
_TEXT	SEGMENT
_bb$ = 8
?leastSigBit64@@YAH_K@Z PROC NEAR			; leastSigBit64

; 320  :     unsigned long bb0, bb1;
; 321  :     int bbHalf;
; 322  :
; 323  :     bb0 = ((unsigned long*)&bb)[0];

	mov	eax, DWORD PTR _bb$[esp-4]

; 324  :     bb1 = ((unsigned long*)&bb)[1];     // if bb in registers, no code
; 325  :     bbHalf = (bb0 == 0);

	xor	ecx, ecx
	test	eax, eax
	sete	cl

; 326  :     if (bbHalf) bb0 = bb1;              // will code as cmov (ideally)

	test	ecx, ecx
	je	SHORT $L806
	mov	eax, DWORD PTR _bb$[esp]
$L806:

; 327  :     bb0 ^= bb0 - 1;

	lea	edx, DWORD PTR [eax-1]
	xor	edx, eax

; 328  :     bb0 *= MT32magic;

	imul	edx, 130329821				; 07c4acddH

; 329  :     return (bbHalf << 5) | MT32table[bb0 >> 27];

	shr	edx, 27					; 0000001bH
	movzx	eax, BYTE PTR _MT32table[edx]
	shl	ecx, 5
	or	eax, ecx

; 330  :         // if bbHalf in byte-addressable register, bitwise-or
; 331  :         // preferred to avoid int+char type/sizing conflict
; 332  : }

	ret	0
?leastSigBit64@@YAH_K@Z ENDP				; leastSigBit64



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