Load from a 64-bit address into other register than rax

From the MOV instruction document you can see that you can move a 64-bit immediate to any registers, but loads/stores involving a 64-bit immediate absolute address can only work with Areg

Opcode Instruction Description
A0 MOV AL,moffs8* Move byte at (seg:offset) to AL.
REX.W + A0 MOV AL,moffs8* Move byte at (offset) to AL.
A1 MOV AX,moffs16* Move word at (seg:offset) to AX.
A1 MOV EAX,moffs32* Move doubleword at (seg:offset) to EAX.
REX.W + A1 MOV RAX,moffs64* Move quadword at (offset) to RAX.
A2 MOV moffs8,AL Move AL to (seg:offset).
REX.W + A2 MOV moffs8***,AL Move AL to (offset).
A3 MOV moffs16*,AX Move AX to (seg:offset).
A3 MOV moffs32*,EAX Move EAX to (seg:offset).
REX.W + A3 MOV moffs64*,RAX Move RAX to (offset).

As you can see there’s no ModR/M byte to encode the register number. Since this is less commonly used than moving a 64-bit immediate to a register it won’t be a problem. If really needed it can be done in 2 instructions

MOVABS is the GAS opcode name for the MOV opcode forms MOV Areg, [Offs64] and MOV [Offs64], Areg. In Yasm’s NASM syntax mode, you can get this form by saying MOV AX, [qword xxx]. Yasm’s GAS syntax mode accepts MOVABS (for GAS compatibility). Note this form is only valid with Areg (AL/AX/EAX/RAX) as the source/destination register.

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

Leave a Comment