The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
June 04, 2023, 09:42:54 AM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  General Forums
| |-+  The Campus
| | |-+  EXE Jump Tables
« previous next »
Pages: 1 2 3 [4] 5 6 ... 9 Print
Author Topic: EXE Jump Tables  (Read 75854 times)
dedndave
Member
*****
Posts: 12523


Re: EXE Jump Tables
« Reply #45 on: May 31, 2009, 11:28:13 AM »

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
Logged
MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: EXE Jump Tables
« Reply #46 on: May 31, 2009, 11:38:15 AM »

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

eschew obfuscation
dedndave
Member
*****
Posts: 12523


Re: EXE Jump Tables
« Reply #47 on: May 31, 2009, 11:39:07 AM »

yes - xp sp2 - and holding - lol
Logged
jj2007
Member
*****
Gender: Male
Posts: 6011



Re: EXE Jump Tables
« Reply #48 on: May 31, 2009, 11:40:05 AM »

Why not try a "faster" API?

Code:
.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
Logged

dedndave
Member
*****
Posts: 12523


Re: EXE Jump Tables
« Reply #49 on: May 31, 2009, 11:46:16 AM »

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
Logged
dedndave
Member
*****
Posts: 12523


Re: EXE Jump Tables
« Reply #50 on: May 31, 2009, 11:50:39 AM »

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)
Logged
UtillMasm
Member
*****
Posts: 560

Please use a non offensive avatar


Re: EXE Jump Tables
« Reply #51 on: May 31, 2009, 11:51:42 AM »

Intel Core Duo 1.83Ghz with Vista SP2
Code:
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...
Logged
MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: EXE Jump Tables
« Reply #52 on: May 31, 2009, 11:51:56 AM »

Quote
Why 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.
Logged

eschew obfuscation
dedndave
Member
*****
Posts: 12523


Re: EXE Jump Tables
« Reply #53 on: May 31, 2009, 11:55:36 AM »

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
Logged
MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: EXE Jump Tables
« Reply #54 on: May 31, 2009, 12:33:01 PM »

For a minimal procedure the direct call is consistently 2 cycles faster.
Code:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    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
Code:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    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

Code:
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]
Code:
3 cycles, indirect
1 cycles, direct


[attachment deleted by admin]
Logged

eschew obfuscation
dedndave
Member
*****
Posts: 12523


Re: EXE Jump Tables
« Reply #55 on: May 31, 2009, 12:39:09 PM »

you guys are not paying attention
look at the code i posted
GET THE TARGET ADDRESS
Logged
MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: EXE Jump Tables
« Reply #56 on: May 31, 2009, 12:44:55 PM »

Who pays attention over the weekend?
Logged

eschew obfuscation
dedndave
Member
*****
Posts: 12523


Re: EXE Jump Tables
« Reply #57 on: May 31, 2009, 12:46:44 PM »

lol - is it the weekend already ?
Logged
UtillMasm
Member
*****
Posts: 560

Please use a non offensive avatar


Re: EXE Jump Tables
« Reply #58 on: May 31, 2009, 01:12:18 PM »

for great weekend. wink

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

[attachment deleted by admin]
Logged
MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: EXE Jump Tables
« Reply #59 on: May 31, 2009, 01:39:39 PM »

I can only guess ANSI or Western European.
Logged

eschew obfuscation
Pages: 1 2 3 [4] 5 6 ... 9 Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!