I want to load a 64 bit immediate to %rax
and another to %rax
. I am using gas. The problem is that gas will happily load a 64bit immediate to %rax
or load a 32bit immediate to %rbx
but it will refuse to generate machine code to load a 64bit immediate to %rbx
. What is going on and how can I get around this?
$ echo "movq 0x100000000,%rax" > function.asm && as function.asm -o function.bin && objdump -D function.bin
function.bin: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <.text>:
0: 48 a1 00 00 00 00 01 movabs 0x100000000,%rax
7: 00 00 00
$ echo "movq 0x100000000,%rbx" > function.asm && as function.asm -o function.bin && objdump -D function.bin
function.asm: Assembler messages:
function.asm:1: Error: operand type mismatch for `movq'
$ echo "movq 0x10000,%rbx" > function.asm && as function.asm -o function.bin && objdump -D function.bin
function.bin: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <.text>:
0: 48 8b 1c 25 00 00 01 mov 0x10000,%rbx
7: 00