View Single Post
Old 02-24-2004, 05:03 PM   #13 (permalink)
n0nsensical
Junkie
 
Location: San Francisco
Yeah it looks like it's a couple of cycles slower per swap. Unless there is some crazy x86 instruction I don't know about to do it better.

Code:
mov eax, x
mov ebx, y
xor eax, ebx
xor ebx, eax
xor eax, ebx
mov x, eax
mov y, ebx
vs.

Code:
mov eax, x
mov ebx, y
mov y, eax
mov x, ebx
But these are of course the human-written versions; the Visual Studio compiler generates 9 xors and movs for the first one and 6 for the second.

Last edited by n0nsensical; 02-24-2004 at 05:06 PM..
n0nsensical is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36