Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Implementation of the abs() function [o.t.]

Author: Gerd Isenberg

Date: 13:58:32 07/05/03

Go up one level in this thread


Hi Russell,

nice test, but in a chessprogram codesize matters more than inside a single
loop.

My output on AMD xp2.8+:

       nothing 3951541892 4.396
         abs() 1713113360 5.838
   cmovs_abs() 1713113360 7.300
   cmovl_abs() 1713113360 7.301
     cdq_abs() 1713113360 7.340
    omid_abs() 1713113360 7.902
     sar_abs() 1713113360 8.282
     sbb_abs() 1713113360 8.402
    fish_abs() 1713113360 12.568
  simple_abs() 1713113360 16.063

with inlined abs functions:

       nothing 3951541892 4.346
    omid_abs() 1713113360 5.779!
         abs() 1713113360 5.798
   cmovl_abs() 1713113360 6.359
     sbb_abs() 1713113360 6.389
   cmovs_abs() 1713113360 6.419
     sar_abs() 1713113360 6.549
     cdq_abs() 1713113360 6.770
  simple_abs() 1713113360 9.323
    fish_abs() 1713113360 10.996


if you put
__asm int 3
before abs() you may inspect the assembler output:

00401026 99                   cdq
00401027 33 C2                xor         eax,edx
00401029 2B C2                sub         eax,edx

but the inlined __asm cdq_abs sucks because of parameter passing:

004011F5 89 44 24 0C          mov         dword ptr [esp+0Ch],eax
004011F9 8B 44 24 0C          mov         eax,dword ptr [esp+0Ch]
004011FD 99                   cdq
004011FE 33 C2                xor         eax,edx
00401200 2B C2                sub         eax,edx

Regards,
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.