汇编语言的定时器

时间:2014-04-05 22:56:21

标签: assembly x86 masm irvine32

我可以使用什么来计算汇编语言的循环(例如c ++上的clock_t)?

我需要花时间来完成总和。这是我的代码:

TITLE Summing an Array               (SumArray.asm)

; This program sums an array of words.

INCLUDE Irvine32.inc

.data
intarray DWORD 10000h,20000h,30000h,40000h, 50000h, 60000h, 70000h

.code
main PROC

mov  edi,OFFSET intarray ; 1: EDI = address of intarray
mov  ecx,LENGTHOF intarray ; 2: initialize loop counter
mov  eax,0 ; 3: sum = 0
L1: ; 4: mark beginning of loop
add  eax,[edi] ; 5: add an integer
add  edi,TYPE intarray ; 6: point to next element

call dumpRegs

loop L1 ; 7: repeat until ECX = 0



exit

main ENDP
END main

1 个答案:

答案 0 :(得分:0)

您可以使用rdtsc获取您感兴趣的代码之前和之后time stamp counter的值,并从“之后”值中减去“之前”值。