Moving
(http://www.thelonestarmover.com/images/pic_carry_furniture_truck.jpg)
Or
Push-Pop
(http://www.wackypackages.org/realproductsscans/2004/jk/pushpop_small.jpg)
moving
Raspberry-Lemonade
Artificially flavored
hah!
How about XCHG REG,REG
Isn't xchg eax,eax the exact same microcode for nop?
it is indeed. regardless i think he wants to move/copy register contents as opposed to swap their values
depends on the registers, the cpu mode, the cpu, the phase of the moon...
with newer architectures, push/pop is often the best choice
push/pop reg32 's are single-byte instructions
that means they consume less cache space - more code fits in the cache
push x - 5 bytes
pop y - 5 bytes
10 bytes total.
mov reg,x - 5 bytes (4 bytes data, 1 byte op-code with dest encoded into op-code)
mov y,reg - 5 bytes
10 bytes total.
I think that is correct.
According to the Intel manual (Vol. 2. PDF Page 442):
QuoteA1 - MOV EAX,moffs32* Move doubleword at (seg:offset) to EAX
So A1 means MOVe to EAX in a single byte.
In terms of actual speed - great question. Even if you used more clock cycles in the mov, would the speed difference between register access vs. a memory access be quicker overall?
Best regards,
Astro.
If you run it on an OoO processor, the mov's should be faster overall. All other things being equal, a PUSH/POP pair generates 6 uops, whereas the MOV only generates 3 (you take the extra hit for doing the stack pointer math). Plus, since I believe they use different ports, the two MOV commands should be able to go through at the same time, assuming both values are in the cache. The PUSH/POP use the same ones, so it would have to do them sequentially. I'm not too sure about that, so don't quote me, I have to go look that up when I get a moment.
-r
I did loads of speed test on pushes and pops and found them to be slow, I posted the results here at the time.