News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Help with QueryPerformanceCounter and 64 bit numbers

Started by Lonewolff, April 12, 2018, 03:15:46 PM

Previous topic - Next topic

Siekmanski

Quote from: LordAdef on April 13, 2018, 10:26:40 PM
QuoteMaybe better to keep it all in the FPU then you can also make a reciprocal of PerfCountFreq and get rid of the fidiv instruction and replace it with fmul.

This is the Jochen! nice

Or the Marinus if you like SIMD  :biggrin:
Creative coders use backward thinking techniques as a strategy.

Siekmanski

I presume your goal is to use the timers for your Games am I right?

If you like it I could post an example of my multimedia timers.
It handles TotalTime, TimeElapsed, FramesPerSecond, FrameTimeDelta and 15 additional resettable timers for game events.
But it is written in SIMD.  :biggrin:
Creative coders use backward thinking techniques as a strategy.

LordAdef

Quote from: Siekmanski on April 13, 2018, 10:52:32 PM
I presume your goal is to use the timers for your Games am I right?

If you like it I could post an example of my multimedia timers.
It handles TotalTime, TimeElapsed, FramesPerSecond, FrameTimeDelta and 15 additional resettable timers for game events.
But it is written in SIMD.  :biggrin:

Yes! And it's in the main loop, so it must be optimized. I would love if you could do that! Thanks Marinus

Siekmanski

Creative coders use backward thinking techniques as a strategy.


LordAdef

Quote from: Siekmanski on April 12, 2018, 06:33:30 PM
I adjusted the code in my previous post.

The Update_frame proc would be something like this:


FrameCounter                dd 0
TimeCounter                 real4 0.0
FrameTimeCounter            real4 0.0
FramesPerSecond             real4 0.0


    invoke      QueryPerformanceCounter,addr FrameTimeNew
    mov         eax,FrameTimeNew.Low32bit
    mov         ecx,eax
    sub         eax,FrameTimeOld.Low32bit
    mov         FrameTimeOld.Low32bit,ecx
    cvtsi2ss    xmm0,eax
    mulss       xmm0,TicksPerSecondReciprocal
    movss       FrameTimeDelta,xmm0 ; FPS = 1 / FrameTimeDelta

    movss       xmm1,TimeCounter
    addss       xmm1,xmm0
    movss       TimeCounter,xmm1

    inc         FrameCounter
    movss       xmm1,FrameTimeCounter
    addss       xmm1,xmm0
    comiss      xmm1,FLT4(1.0)
    jb          PerSecond
    cvtsi2ss    xmm0,FrameCounter
    divss       xmm0,xmm1
    movss       FramesPerSecond,xmm0  ; update per second
    mov         FrameCounter,0       
    xorps       xmm1,xmm1
PerSecond:   
    movss       FrameTimeCounter,xmm1


Marinus and friends,

Uasm is complaining of :

;comiss xmm1, FLT4(1.0)
Main.asm(281) : Error A2273: real or BCD number not allowed


It's the FLT4 macro. Any idea?

jj2007


Siekmanski

Or use it as a constant.

.const

fp1 real4 1.0

.code

    comiss      xmm1,fp1

Creative coders use backward thinking techniques as a strategy.

aw27


jj2007

Quote from: aw27 on May 16, 2018, 06:17:53 PM
FP4 is an "built-in" UASM macro

No, it's from the Masm32 SDK (\masm32\macros\macros.asm):    ; **********************************************************
    ; function style macros for direct insertion of data types *
    ; **********************************************************

      FP4 MACRO value
        LOCAL vname
        .data
        align 4
          vname REAL4 value
        .code
        EXITM <vname>
      ENDM

      FP8 MACRO value
        LOCAL vname
        .data
        align 4
          vname REAL8 value
        .code
        EXITM <vname>
      ENDM

      FP10 MACRO value
        LOCAL vname
        .data
        align 4
          vname REAL10 value
        .code
        EXITM <vname>
      ENDM


Usage:include \masm32\include\masm32rt.inc

.code
start:
  int 3
  fld FP4(123.456)
  exit

end start

aw27

Quote
No, it's from the Masm32 SDK (\masm32\macros\macros.asm):
When you have some time download UASM and read the uasm246_ext.pdf
Then try to make a project without using the "include \masm32\include\masm32rt.inc" (if you still remember how to do it of course).
To your surprise you will see that UASM can figure out what FP4 is.

aw27

Quote
No, it's from the Masm32 SDK (\masm32\macros\macros.asm):
When you have some time download UASM and read the uasm246_ext.pdf
Then try to make a project without using the "include \masm32\include\masm32rt.inc" (if you still remember how to do it of course).
To your surprise  :dazzled: you will see that UASM can figure out what FP4 is.

HSE

Equations in Assembly: SmplMath

aw27


LordAdef

thanks everyone.


So, how about FLT4, where is this macro from?