Save some clocks ?

From: Andrew Kennedy (andrewkennedy2_at_LOGev1.net)
Date: 02/26/04

  • Next message: Andrew Kennedy: "Re: Where can I get tasm?"
    Date: Thu, 26 Feb 2004 08:02:54 +0000 (UTC)
    
    

    Any comment on the comment near the bottom that someone gave me about the
    jmp + 2.

    xor eax, eax
    cpuid
    rdtsc
    mov edi, eax ; save lower 32 bits in edi
    xor eax, eax
    cpuid

    ; Insert timed code here

    xor eax, eax
    cpuid
    rdtsc
    sub edi, eax
    xor eax, eax
    sub eax, edi ; eax = result

    Joined: 19 May 2003
    Posts: 372
    Location: 8003F000
    PostPosted: 02-25-2004 07:44 PM Post subject: Reply with quote
    You don't have to use "cpuid" instruction.
    "jmp $+2" puts the CPU back into order too, and
    doesn't run 200 clocks, like "cpuid".


  • Next message: Andrew Kennedy: "Re: Where can I get tasm?"

    Relevant Pages

    • Re: cpuid
      ... CPUID returns various information about the processor it is being ... registers EAX, EBX, ECX and EDX with information, which varies ... CPUID also acts as a barrier to serialise instruction execution: ... · If EAX is zero on input, EAX on output holds the maximum acceptable ...
      (comp.lang.asm.x86)
    • Re: rdtsc on Athlon 64 x2 speeds up, slows down
      ... > after RDTSC, and before each CPUID an XOR EAX, EAX ...
      (comp.lang.asm.x86)
    • Re: How to measure my application speed ?
      ... xor eax, eax ... mov edi, eax; Don't use edi in your code ... forces the 2 rdtsc instructions to occur at a precise moment. ...
      (comp.lang.asm.x86)
    • Re: timing
      ... > I'm timing delays between pixels drawn on a monitor of 1024x768 ... The cpuid instruction can be used to force instructions ... >> xor eax, eax ...
      (comp.lang.asm.x86)
    • Re: RTDSC on atlhon
      ... It says that you have to use CPUID with RDTSC: ... xor eax, eax ...
      (comp.lang.asm.x86)