View Single Post
Old 02-24-2004, 06:27 PM   #14 (permalink)
Pragma
I am Winter Born
 
Pragma's Avatar
 
Location: Alexandria, VA
Quote:
Originally posted by madcow
So it is less efficient even though you can write it on one line. The code using XOR is also much harder for people to glance at and understand.
So remember kids, writing slick code like this isn't necessarily better.
Well, yes and no. The xor code isn't necessarily for everyone, but when you get down to writing hardcore assembly for systems level programming, you'll use the XOR version.

Also, as an amusing note, here's a funny bit:
Quote:
C Code:
int x = 0;
Quote:
ASM Code:
xorl %eax,%eax
Why XOR instead of movl $0,%eax? Because the XOR version is faster.
Pragma 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76