Announcement

Collapse
No announcement yet.

Inline ASM return QUAD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Inline ASM return QUAD

    Hello Everyone,

    I need some pointers on how to get an inline asm function to return a quad. I'm playing around with making "unique" numbers so I though i would investigate the TimeStampCounter(RDTSC). This instruction returns it's result in EAX and EDX.

    Code:
    function GetTimeStamp() as quad
        asm dw &H0310F ;opcode for RDTSC
        asm mov function[0],eax
        asm mov function[4],edx
    end function
    This just doesn't do the job. I also want to know why the instruction RDTSC gives me a syntax error when used inline.
    Code:
    asm RDTSC **NO GO**
    ------------------
    Cheers!

    [This message has been edited by mark smit (edited April 22, 2001).]

  • #2
    RDTSC is Pentium specific instruction. Somehow I made some experiments and found this command unuseful under Windows.
    A reason is simple - to have correct timing it's necessary to disabke interrupts (CLI/STI), but Windows (at least, Win2000) doesn't allow to do this.
    As result - I ran a program several time and had different timing.

    ------------------
    E-MAIL: [email protected]

    Comment


    • #3
      Hello Semen,

      For my purposes the counter accuracy is not important. I just need to know how an inline assembly function can return a quad type. But thanks for the information



      ------------------
      Cheers!

      Comment


      • #4
        Mark --
        all works as expected and similar your function.

        Code:
           #Compile Exe
           #Dim All
           #Register None
           
           %Lo = 123456
           %Hi = 7890   
           
           Function GetTimeStamp() As Quad
              ! MOV EAX, %Lo
              ! MOV Function, EAX
              ! MOV EAX, %Hi
              ! MOV Function[4], EAX
           End Function
        
           Function PbMain
              Dim x As Quad
              x = GetTimeStamp
              If Str$(x, 18) = Str$(%Lo + %Hi * &H100000000&&, 18) Then MsgBox "Ok"
           End Function
        ------------------
        E-MAIL: [email protected]

        Comment


        • #5
          Mark,

          This will do the job OK but be warned that as a timer, it suffers
          interference from the operating system that makes its accuracy of
          limited use.

          In practical terms, GetTickCount() has the same effective resolution
          once you calculate the average interference fromthe operating system.

          Code:
            FUNCTION Get_RDTSC() as QUAD
            
                LOCAL BigVar as QUAD
            
                ! db &H0F, &HA2 ; CPUID < clear pipeline
                ! db &H0F, &H31 ; RDTSC < get timer
            
                ! mov BigVar[0], eax
                ! mov BigVar[4], edx
            
                FUNCTION = BigVar
            
            END FUNCTION
          Regards,

          [email protected]


          [This message has been edited by Steve Hutchesson (edited April 22, 2001).]
          hutch at movsd dot com
          The MASM Forum

          www.masm32.com

          Comment

          Working...
          X