Assembly examples in wiki (xor vs. mov)
Posted: Fri Aug 22, 2008 12:08 pm
Hi there,
first of all I have to say that this wiki is great. I was always interested in doing some more with assembly language and the whole low level x86 architecture. This wiki helped me a lot in the last few days.
But I always read something like this in the examples in the wiki to set a register to zero:
"xor ax, ax"
Why? Yes, it does what it is supposed to do and I also know why, but why do you always use xor insted of mov?
"mov ax, 0" will do its job too, wouldn't it?
Do you use xor because it takes less cpu cycles? That's the only reason that came into my mind for this.
Thanks for your answers,
Andy
first of all I have to say that this wiki is great. I was always interested in doing some more with assembly language and the whole low level x86 architecture. This wiki helped me a lot in the last few days.
But I always read something like this in the examples in the wiki to set a register to zero:
"xor ax, ax"
Why? Yes, it does what it is supposed to do and I also know why, but why do you always use xor insted of mov?
"mov ax, 0" will do its job too, wouldn't it?
Do you use xor because it takes less cpu cycles? That's the only reason that came into my mind for this.
Thanks for your answers,
Andy