push hInstance
pop wc.hInstance


mov eax,hInstance
mov wc.hInstance,eax

which is faster?

Posted on 2004-06-14 08:51:26 by Theo
mov. And it's shorter, too, for this example.

But think about it - the mov way only has two memory references (read and write), and only touch EAX. the push/pop has read, store to stack, read stack, store to memory, plus modification of the ESP register.
Posted on 2004-06-14 09:12:43 by f0dder
..and mov version can be even faster if you consider pairing, what means that you don't use the eax register immediatily after modifying it. Just put something else between.
Posted on 2004-06-14 12:00:52 by Petroizki
In my opinion:
mov versiyon: Fast+Big
stack versiyon: Slow+Small
Posted on 2004-06-14 12:07:02 by Criminal2
No, the mov version is always smaller or equal in size, except when the source operand is an immediate dword between -128 and 127.
Posted on 2004-06-14 13:50:26 by Sephiroth3
Here's what hexit assembles...

ebp-referenced (locals), mov vs pushpop

00000000 8B8500100000 mov eax,[ebp+000001000]
00000006 898504100000 mov [ebp+000001004],eax
0000000C FFB504100000 push d.[ebp+000001004]
00000012 8F8504100000 pop d.[ebp+000001004]

static memory, mov vs pushpop

00000018 A100100000 mov eax,[000001000]
0000001D A304100000 mov [000001004],eax
00000022 FF3500100000 push d.[000001000]
00000028 8F0504100000 pop d.[000001004]
Posted on 2004-06-14 14:04:04 by f0dder