Hi,

These two instructions are equivalent:

movq $0x12345678, %rax
movl $0x12345678, %eax

But gas (2.17.50.0.12 on Fedora 7) chooses a longer encoding for the
former:

  22:   48 c7 c0 78 56 34 12    mov    $0x12345678,%rax
  29:   b8 78 56 34 12          mov    $0x12345678,%eax

In fact, for any non-negative immediate constant that fits in 32 bits,
it's better to use the "mov imm32, r32" instruction (0xb8), rather
than "mov imm32, r64" (REX 0xc7).  Negative constants need the
sign-extending effect of REX 0xc7.

gcc-generated assembly doesn't seem to run into this, but hand-coded
assembly often does (see for example the x86-64 Linux kernel).


David Wragg


_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to