The MASM Forum

General => The Campus => Topic started by: Magnum on March 03, 2013, 02:11:26 PM

Title: Cycles for code run time
Post by: Magnum on March 03, 2013, 02:11:26 PM
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

Title: Re: Cycles for code run time
Post by: jj2007 on March 03, 2013, 06:22:06 PM
I see just error messags, Andy. Can it be that you forgot some headers?
Title: Re: Cycles for code run time
Post by: dedndave on March 03, 2013, 08:25:09 PM
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 (http://masm32.com/board/index.php?topic=49.0)