Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bit Operation

Author: Dann Corbit

Date: 19:48:40 05/21/02

Go up one level in this thread


GCC 3.1 emits this:

	.file	"foo.c"
	.text
	.align 2
	.p2align 4,,15
.globl _reversebits
	.def	_reversebits;	.scl	2;	.type	32;	.endef
_reversebits:
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	popl	%ebp
	movl	%eax, %ecx
	andl	$1431655765, %eax
	andl	$-1431655766, %ecx
	shrl	%ecx
	addl	%eax, %eax
	orl	%ecx, %eax
	movl	%eax, %ecx
	andl	$858993459, %eax
	andl	$-858993460, %ecx
	shrl	$2, %ecx
	sall	$2, %eax
	orl	%ecx, %eax
	movl	%eax, %ecx
	andl	$252645135, %eax
	andl	$-252645136, %ecx
	shrl	$4, %ecx
	sall	$4, %eax
	orl	%ecx, %eax
	movl	%eax, %ecx
	andl	$16711935, %eax
	andl	$-16711936, %ecx
	shrl	$8, %ecx
	sall	$8, %eax
	orl	%ecx, %eax
	roll	$16, %eax
	ret

MS VC++ emits this:
; Listing generated by Microsoft (R) Optimizing Compiler Version 12.00.9044.0

	TITLE	foo.c
	.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT	SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT	ENDS
_DATA	SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA	ENDS
CONST	SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST	ENDS
_BSS	SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS	ENDS
$$SYMBOLS	SEGMENT BYTE USE32 'DEBSYM'
$$SYMBOLS	ENDS
_TLS	SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS	ENDS
FLAT	GROUP _DATA, CONST, _BSS
	ASSUME	CS: FLAT, DS: FLAT, SS: FLAT
endif

INCLUDELIB LIBC
INCLUDELIB OLDNAMES

PUBLIC	_reversebits
; Function compile flags: /Ogty
_TEXT	SEGMENT
_x$ = 8
_reversebits PROC NEAR
; File foo.c
; Line 4
	mov	eax, DWORD PTR _x$[esp-4]
	lea	ecx, DWORD PTR [eax+eax]
	shr	eax, 1
	xor	eax, ecx
	and	eax, 1431655765				; 55555555H
	xor	eax, ecx
; Line 5
	lea	ecx, DWORD PTR [eax*4]
	shr	eax, 2
	xor	eax, ecx
	and	eax, 858993459				; 33333333H
	xor	eax, ecx
; Line 6
	mov	ecx, eax
	shr	eax, 4
	shl	ecx, 4
	xor	eax, ecx
	and	eax, 252645135				; 0f0f0f0fH
	xor	eax, ecx
; Line 7
	mov	ecx, eax
	shr	eax, 8
	shl	ecx, 8
	xor	eax, ecx
	and	eax, 16711935				; 00ff00ffH
	xor	eax, ecx
	mov	ecx, eax
; Line 8
	shr	eax, 16					; 00000010H
	shl	ecx, 16					; 00000010H
	or	eax, ecx
; Line 10
	ret	0
_reversebits ENDP
_TEXT	ENDS
END

Intel C++ 5.0 emits this:

; -- Machine type EFI
	.686P
 	.387
_TEXT	SEGMENT PARA PUBLIC USE32 'CODE'
_TEXT	ENDS
_DATA	SEGMENT PARA PUBLIC USE32 'DATA'
	ALIGN 010H
_DATA	ENDS
_BSS	SEGMENT PARA PUBLIC USE32 'BSS'
	ALIGN 010H
_BSS	ENDS
_RDATA	SEGMENT PARA PUBLIC USE32 'DATA'
	ALIGN 010H
_RDATA	ENDS
_TLS	SEGMENT PARA PUBLIC USE32 'TLS'
	ALIGN 010H
_TLS	ENDS
_DATA1	SEGMENT PARA PUBLIC USE32 'DATA'
	ALIGN 010H
_DATA1	ENDS
_TEXT1	SEGMENT PARA PUBLIC USE32 'CODE'
	ALIGN 010H
_TEXT1	ENDS
	ASSUME	CS:FLAT,DS:FLAT,SS:FLAT
;ident "Intel(R) C++ Compiler for 32-bit applications, Version 5.0.1   Build
020125Z  : C:\tmp\foo.c : -Qvc6 -Qlocation,link,C:\lang\VC98\bin -Qvc6
-Qlocation,link,C:\lang\VC98\bin -Qvc6 -Qlocation,link,C:\lang\VC98\bin -Qvc6
-Qlocation,link,C:\lang\VC98\bin -Qvc6 -Qlocation,link,C:\lang\VC98\bin -Qvc6
-Qlocation,link,C:\lang\VC98\bin -nologo -G6 -Gr -ML -W3 -O2 -Ob0 -D WIN32 -D
NDEBUG -D _CONSOLE -D _MBCS -D UNIT_TEST -FA -FaRelease/ -FpRelease/foo.pch -YX
-FoRelease/ -FdRelease/ -FD -G7 -O3 -Qip -QaxW -c"
_TEXT	SEGMENT PARA PUBLIC USE32 'CODE'
_DATA	ENDS
; -- End  _main$A
_DATA	SEGMENT PARA PUBLIC USE32 'DATA'
_DATA	ENDS
_TEXT	SEGMENT PARA PUBLIC USE32 'CODE'
;	COMDAT @reversebits@4
; -- Begin  @reversebits@4
; mark_begin;
       ALIGN     4
; parameter 1: ecx
	PUBLIC   @reversebits@4
@reversebits@4	PROC NEAR
$B4$1:                          ; Preds $B4$0
        mov       edx, ecx                                      ;4.11
        and       ecx, 1431655765                               ;4.37
        and       edx, -1431655766                              ;4.11
        shr       edx, 1                                        ;4.11
        add       ecx, ecx                                      ;4.37
        or        edx, ecx                                      ;4.37
        mov       eax, edx                                      ;5.11
        and       edx, 858993459                                ;5.37
        and       eax, -858993460                               ;5.11
        shr       eax, 2                                        ;5.11
        add       edx, edx                                      ;5.37
        add       edx, edx                                      ;5.37
        or        eax, edx                                      ;5.37
        mov       edx, eax                                      ;6.11
        and       edx, -252645136                               ;6.11
        shr       edx, 4                                        ;6.11
        and       eax, 252645135                                ;6.37
        shl       eax, 4                                        ;6.37
        or        edx, eax                                      ;6.37
        mov       eax, edx                                      ;7.11
        and       eax, -16711936                                ;7.11
        and       edx, 16711935                                 ;7.37
        shr       eax, 8                                        ;7.11
        shl       edx, 8                                        ;7.37
        or        eax, edx                                      ;7.37
        rol       eax, 16                                       ;8.22
        ret                                                     ;9.12
        ALIGN     4
                                ; LOE
; mark_end;
@reversebits@4 ENDP
;@reversebits@4	ENDS
_TEXT	ENDS
_DATA	SEGMENT PARA PUBLIC USE32 'DATA'
_DATA	ENDS
; -- End  @reversebits@4



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.