CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Other Programming > Assembly
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Assembly Questions and Answers for Assembly here!

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old February 1st, 2005, 01:02 PM
    Alana Radesch Alana Radesch is offline
    Junior Member
     
    Join Date: Jan 2005
    Location: Oostende, Belgium
    Posts: 13
    Alana Radesch is an unknown quantity at this point (<10)
    Weird results...

    I have assembly routine in my code where main loop for function is:
    Code:
      label:   mov ecx,[esi+ebx]
      		  adc  [edi+ebx],ecx
      		  lea   ebx,[ebx+4]
      		  dec  eax
      		  jnz   label
    Timing (with 'rdtsc') showed this loop running at 10,5 cycles per loop.

    This is running slower than reference code in C++ (optimized speed) running at 6.6 cycles per loop. This C++ code is 15 instructions per loop (3 times as much as asm loop) ???

    My calculations say this asm loop should run at 4.4 cycles per loop. but it is not. it is 10.5.

    If I change ADC to ADD, loop indeed takes 4.4cycles. Why is ADC so slow ? It should be same speed as ADD no ?
    Reply With Quote
      #2    
    Old February 1st, 2005, 03:19 PM
    OReubens OReubens is offline
    Senior Member
     
    Join Date: Apr 2000
    Location: Belgium (Europe)
    Posts: 2,038
    OReubens  is a jewel in the rough (300+)OReubens  is a jewel in the rough (300+)OReubens  is a jewel in the rough (300+)OReubens  is a jewel in the rough (300+)
    Re: Weird results...

    Well... On P4 and up, ADC is actually one of the instructions you would want to avoid because it is slow (significantly slower than ADD, although it does depend on the code sequence)

    Note that with carefull selection the P4 can have 4 instructions executing (practically) concurrently. So with the right kind of instructions in the right order a code sequence that is 4 times as large as the code here (5 instrcutions) could still be just as fast.

    The loop seems to indicate you are doing large integer math ? If this is the case, and you need the extra speed (and you obviously have a P4), you might want to go with using MMX/SSE instructions to higher overall throughput.
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Other Programming > Assembly


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:47 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009