push hInstance
pop wc.hInstance
and
mov eax,hInstance
mov wc.hInstance,eax
which is faster?
:stupid:
pop wc.hInstance
and
mov eax,hInstance
mov wc.hInstance,eax
which is faster?
:stupid:
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.
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.
..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.
In my opinion:
mov versiyon: Fast+Big
stack versiyon: Slow+Small
mov versiyon: Fast+Big
stack versiyon: Slow+Small
No, the mov version is always smaller or equal in size, except when the source operand is an immediate dword between -128 and 127.
Here's what hexit assembles...
ebp-referenced (locals), mov vs pushpop
static memory, mov vs pushpop
ebp-referenced (locals), mov vs pushpop
00000000 8B8500100000 mov eax,[ebp+000001000]
00000006 898504100000 mov [ebp+000001004],eax
vs.
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
vs.
00000022 FF3500100000 push d.[000001000]
00000028 8F0504100000 pop d.[000001004]