News:

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

Main Menu

Cycles for code run time

Started by Magnum, March 03, 2013, 02:11:26 PM

Previous topic - Next topic

Magnum

I would like to get this to show the cycles, the code below shows 10 1s.

Thanks.


Loop_Count = 10000  ;adjust the loop count so that each pass takes about 0.5 seconds


.DATA


.DATA?

.CODE

_main   PROC

INVOKE  GetCurrentProcess
INVOKE  SetProcessAffinityMask,eax,1
INVOKE  Sleep,750

mov     ecx,10

Loop00:

push    ecx

counter_begin Loop_Count,HIGH_PRIORITY_CLASS

;put your code to be timed here

xor eax,eax
xorps XMM0,XMM0  ; Clear xmm0
mov   eax,7
movd XMM0,eax
nop
movd ebx,XMM0


counter_end

print   ustr$(eax),44,32
        pop     ecx
        dec     ecx
        jnz     Loop00

        print   chr$(13,10)

inkey

INVOKE  ExitProcess,0

_main   ENDP

END     _main

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

jj2007

I see just error messags, Andy. Can it be that you forgot some headers?

dedndave

Jochen is right
i added the following to the beginning of the source
        .XCREF
        .NoList
        INCLUDE    \Masm32\Include\Masm32rt.inc
        .686p
        .MMX
        .XMM
        INCLUDE    \Masm32\Macros\Timers.asm
        .List


then, i adjusted the loop count
Loop_Count = 100000000

on a P4 prescott...
2, 2, 1, 2, 1, 1, 1, 1, 2, 1

if you don't already have Michael's timers.asm in the masm32\macros folder...
http://masm32.com/board/index.php?topic=49.0