.686
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib

include \masm32\macros\macros.asm
include TIMERS.ASM
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
LOOP_COUNT EQU 1000000000
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
test1 proc

print "lea esp,  : "
counter_begin LOOP_COUNT,HIGH_PRIORITY_CLASS
lea esp,
counter_end
print ustr$(eax)," cycles",13,10

ret
test1 endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
test2 proc
print "7 * nop : "
counter_begin LOOP_COUNT,HIGH_PRIORITY_CLASS
nop
nop
nop
nop
nop
nop
nop
counter_end
print ustr$(eax)," cycles",13,10

ret
test2 endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
mov eax,LOOP_COUNT
print ustr$(eax)," counts",13,10
invoke test1
invoke test2

mov eax, input(13,10,13,10,"Press ENTER key to exit...")
        invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

end start

f0dder said:
"Interesting that they chose an instruction like "mov edi, edi" instead of just
two NOPs. Then again, you need a two-byte instruction to make sure no thread is
about to execute NOP#2 when the jump-destination is written."

arafel asked
"What is the reason behind MASM choosing stuff like "lea?? ebx," for padding.
Wouldn't be better (for execution speed when aligning code) to do equivalent number
of nops instead?"

i tested:
;-----------------------------------------------------
1000000000 counts
lea esp,  : 1 cycles
7 * nop : 1 cycles

Press ENTER key to exit...
;-----------------------------------------------------
however you changed the LOOP_COUNT, the result is same
I think the Timers.asm has some problem.

Hope you explain some detail.
Attachments:
Posted on 2006-07-31 01:35:18 by dcskm4200