News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

EXE Jump Tables

Started by dedndave, May 29, 2009, 05:51:54 PM

Previous topic - Next topic

dedndave

dual-core prescott....

13828614

direct indirect
------ --------
32608   32794
32285   33110
33037   33008
32435   33149
33087   32608
32551   33496
32165   28947
31687   31494
29901   31369
31580   30794
31328   31350
30840   30946
31516   30736
31468   31378
30782   31489
31116   31100
30823   31301
31092   32632
33431   31313
30686   30589
------ --------
634418  633603

as you can see, my numbers are slightly higher - lol
sumpin's not right, here - this dual-core @ 3 Ghz performs fairly well

MichaelW

You're running XP? My numbers were for 2000.
eschew obfuscation

dedndave

yes - xp sp2 - and holding - lol

jj2007

Why not try a "faster" API?

.nolist
include \masm32\include\masm32rt.inc
.686
include \masm32\macros\timers.asm
LOOP_COUNT = 100000

EXTERNDEF _imp__GetTickCount@0:PTR pr0

.code
start:
counter_begin LOOP_COUNT, HIGH_PRIORITY_CLASS
REPEAT 100
   invoke GetTickCount
ENDM
counter_end
print str$(eax), 9, "cycles for 100*GetTickCount, indirect", 13, 10

counter_begin LOOP_COUNT, HIGH_PRIORITY_CLASS
REPEAT 100
  invoke _imp__GetTickCount@0
ENDM
counter_end
print str$(eax), 9, "cycles for 100*GetTickCount, direct", 13, 10

inkey chr$(13, 10, "--- ok ---", 13)
exit
end start

dedndave

yes - i was thinking the same thing
here is a short list of some that i think should be fast...

GetProcessAffinityMask
QueryPerformanceCounter
GetCurrentProcess
CreateTimerQueue
EnterCriticalSection
LeaveCriticalSection

dedndave

i am seeing a 300 cycle diff JJ - 1700 vs 1400

but - all these timing measurements are going to prevent peeps from seeing my post about the replacement code - lol
(this sentance is intended to make them go back and look)

UtillMasm

Intel Core Duo 1.83Ghz with Vista SP2
9570552

direct indirect
------ --------
3661    4399
28143   9589
29073   23326
28886   28982
21307   16514
29851   37303
34544   14749
20351   1805
12799   10889
14832   28986
21583   13989
15321   6758
16165   15626
9959    1466
15746   23869
3090    2793
4223    2726
4613    3774
3178    1507
2827    1698
------ --------
320152  250748

Press any key to exit...

MichaelW

QuoteWhy not try a "faster" API?

I did, I selected one that was faster than SendMessage. If you want to test something fast, forget the API and code a DLL with a procedure that contains only a RET, and call it by the same mechanisms.
eschew obfuscation

dedndave

well - we know that result
it is certain synchronization calls that are of primary interest
but there are some fast APIs (just not the ones we always want to be fast - lol)

btw Michael - you are making me think about switching to Win2K - lol

MichaelW

For a minimal procedure the direct call is consistently 2 cycles faster.

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc

    aret PROTO
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      hInstance dd 0
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

LibMain proc instance:DWORD,reason:DWORD,unused:DWORD

    .if reason == DLL_PROCESS_ATTACH
      push instance
      pop hInstance
      mov eax, TRUE

    .elseif reason == DLL_PROCESS_DETACH

    .elseif reason == DLL_THREAD_ATTACH

    .elseif reason == DLL_THREAD_DETACH

    .endif

    ret

LibMain endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

aret proc
    ret
aret endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end LibMain


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
    .686
    include \masm32\macros\timers.asm

    aret PROTO

    EXTERNDEF _imp__aret@0:NEAR PTR
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    nops 3
    call aret
    nops 3
    call _imp__aret@0
    nops 3

    invoke Sleep, 4000

    counter_begin 1000, HIGH_PRIORITY_CLASS
      call aret
    counter_end
    print ustr$(eax)," cycles, indirect",13,10

    counter_begin 1000, HIGH_PRIORITY_CLASS
      call _imp__aret@0
    counter_end
    print ustr$(eax)," cycles, direct",13,10,13,10

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


00401000 90                     nop
00401001 90                     nop
00401002 90                     nop
00401003 E8F2010000             call    fn_004011FA
00401008 90                     nop
00401009 90                     nop
0040100A 90                     nop
0040100B FF1530204000           call    dword ptr [aret]
00401011 90                     nop
00401012 90                     nop
00401013 90                     nop
. . .
004011FA                    fn_004011FA:
004011FA FF2530204000           jmp     dword ptr [aret]


3 cycles, indirect
1 cycles, direct



[attachment deleted by admin]
eschew obfuscation

dedndave

you guys are not paying attention
look at the code i posted
GET THE TARGET ADDRESS

MichaelW

Who pays attention over the weekend?
eschew obfuscation

dedndave

lol - is it the weekend already ?

UtillMasm

for great weekend. :wink

btw: to dear MichaelW, which one for these text files? :wink

[attachment deleted by admin]

MichaelW

I can only guess ANSI or Western European.
eschew obfuscation