Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: shift right 32 bit assembly

Author: Gerd Isenberg

Date: 11:04:52 11/01/05

Go up one level in this thread


On November 01, 2005 at 12:39:23, giuseppe wrote:

>hi,
>
>in viusal c++ the the number of opcode of solution 1 is major of code of
>solution 2
>why sample 1 is more fast of solution 2 ?
>
>
>unsigned buf
>U64 n64
>
>
>****** solution 1 *******
>buf = n64 >> 32;
>//the disassembly generated code is this:
>//0040AB6A   mov         ecx,20h
>//0040AB6F   mov         eax,dword ptr [ebp-8]
>//0040AB72   mov         edx,dword ptr [ebp-4]
>//0040AB75   call        _aullshr (0040f2c0)
>//0040AB7A   mov         dword ptr [ebp-0Ch],eax
>**************************
>
>
>****** solution 2 ********
>__asm{
> mov eax, dword ptr n64+04h
> mov buf, eax
>}
>**************************


Hi Giuseppe,

Inline assembler most likely disables some optimizations due to sideeffects
(writing to a global variable), not controlled by the compiler.

OTOH your assembly looks like generated with disabled (debug) optimization.
With some optimization enabled your compiler should produce the intended code
for a release version.

  ...
  buf = n64 >> 32;

msvc6 generates:
; Function compile flags: /Ogtpy
  mov  eax, DWORD PTR ?n64@@3_KA+4
  mov  DWORD PTR ?buf@@3IA, eax

Gerd



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.