Booting from a 64-bit address to a different register than rax

On x64, booting from a 64-bit absolute address (i.e. dereferencing a 64-bit immediate) can be done using

movabs addr64, %rax 

However, when the destination register is anything other than rax , the assembler generates an operand size mismatch for movabs error message. What am I missing?

+8
assembly x86-64
source share
2 answers

In no case. It can only be downloaded from Areg

MOVABS is the name of the GAS operation code for the MOV code forms MOV Areg, [Offs64] and MOV [Offs64], Areg .
In Yasm NASM syntax mode, you can get this form by saying MOV AX, [qword xxx] . The syntax of the Yasm GAS mode accepts MOVABS (for compatibility with GAS).
Please note: this form is only valid with Areg (AL / AX / EAX / RAX) as the source / target register. *

http://cvs.tortall.net/pipermail/yasm-devel/2006-March/000579.html

+7
source share

For any register other than %rax , it can be replaced with two instructions:

 48 bb f0 de bc 9a 78 56 34 12 mov $0x123456789abcdef0,%rbx 48 8b 1b mov (%rbx),%rbx 

It's longer than a solo

 48 a1 f0 de bc 9a 78 56 34 12 mov 0x123456789abcdef0,%rax 

so you probably would prefer movabs (the latter) if you can use it.

+3
source share

All Articles