 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
VolatileAce Cheater
Reputation: 0
Joined: 19 Mar 2009 Posts: 30 Location: 0001001100110111
|
Posted: Tue Mar 24, 2009 8:06 pm Post subject: [ASM] Which one runs faster? |
|
|
I'd appreciate it if anyone can point out the faster code (or are generally the same and is dependent on CPU given) and give a brief explanation. Thanks.
Both of the codes assign z the smaller of the two values, x and y.
| Code: | 00D035C3 mov eax,dword ptr [x]
00D035C6 sub eax,dword ptr [y]
00D035C9 mov ecx,dword ptr [x]
00D035CC xor edx,edx
00D035CE cmp ecx,dword ptr [y]
00D035D1 setl dl
00D035D4 neg edx
00D035D6 and eax,edx
00D035D8 add eax,dword ptr [y]
00D035DB mov dword ptr [z],eax
|
| Code: | 00D035DE mov eax,dword ptr [x]
00D035E1 cmp eax,dword ptr [y]
00D035E4 jle main+61h (0D035F1h)
00D035E6 mov ecx,dword ptr [y]
00D035E9 mov dword ptr [ebp-0E8h],ecx
00D035EF jmp main+6Ah (0D035FAh)
00D035F1 mov edx,dword ptr [x]
00D035F4 mov dword ptr [ebp-0E8h],edx
00D035FA mov eax,dword ptr [ebp-0E8h]
00D03600 mov dword ptr [z],eax
|
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Tue Mar 24, 2009 8:25 pm Post subject: |
|
|
| i would say second one because movs are pretty much the fastest instructions. however if you look on masm forums there are some nice code timing macros that you can use. or i think it is already in one of the libraries included when you install masm but i just never used them
|
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Wed Mar 25, 2009 5:14 am Post subject: |
|
|
This first would be faster;
This would be even faster: | Code: | mov eax,dword ptr [x]
mov ecx,dword ptr [y]
cmp eax,ecx
cmovg eax,ecx
mov dword ptr [z],eax |
|
|
| Back to top |
|
 |
arigity Advanced Cheater
Reputation: 0
Joined: 03 Jul 2008 Posts: 65 Location: middle of nowhere.
|
Posted: Wed Mar 25, 2009 7:39 am Post subject: |
|
|
second ones faster.
_________________
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|