Re: Can anyone explain "movl %eax %eax"?

From: Jidong Xiao
Date: Wed Feb 09 2011 - 20:32:46 EST


Thank you David and Peter.

And I found more information in the following website, other people
who are not very clear can have a look at this document:

http://www.x86-64.org/documentation/assembly.html

======================
Implicit zero extend

Results of 32-bit operations are implicitly zero extended to 64-bit
values. This differs from 16 and 8 bit operations, that don't affect
the upper part of registers. This can be used for code size
optimisations in some cases, such as:

movl $1, %eax # one byte shorter movq $1, %rax
xorq %rax, %rax # three byte equivalent of mov $0,%rax
andl $5, %eax # equivalent for andq $5, %eax
======================

Regards
Jidong

On Wed, Feb 9, 2011 at 6:05 PM, David Miller <davem@xxxxxxxxxxxxx> wrote:
> From: Jidong Xiao <jidong.xiao@xxxxxxxxx>
> Date: Wed, 9 Feb 2011 18:02:09 -0500
>
>> Oh, I see. Thank you. So similarly, the operation "xorl %eax,%eax" is
>> used for the same reason, right? I see that appears in more files.
>
> The xorl clears the entire register.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/