Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

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

On x64, loading from a 64-bit absolute address (that is, dereferencing a 64-bit immediate) can be done by

movabs addr64, %rax

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...