Reputation: 535
From Intel64 & IA-32 manual vol 2a, there are many possible usage for instruction mov
. Such as:
mov r64, m64 # move m64 to r64
mov rax, moffs64 # move quadword at (offset) to RAX
I wrote code to test (gas, intel syntax):
movabs rax, label
movabs rax, offset label
...
label:
.quad 0x112233445566
After assembly, linking and objdump, I got related assembly:
mov rax, qword ptr ds:0xffff80000000008e
mov rax, 0xffff80000000008e
Obviously, the second instruction I wrote is not the instruction expected as manual. What's the instruction for the format in the manual?
Upvotes: 0
Views: 1816
Reputation: 58507
moffs
denotes a memory operand. Here's the description from the Intel manual:
moffs8, moffs16, moffs32, moffs64
— A simple memory variable (memory offset) of type byte, word, or doubleword used by some variants of theMOV
instruction. The actual address is given by a simple offset relative to the segment base. NoModR/M
byte is used in the instruction. The number shown withmoffs
indicates its size, which is determined by the address-size attribute of the instruction.
The offset
operator, which is used by assemblers like MASM and TASM, gives you "the offset into the relevant segment of [the operand]" (source). So what you get with offset label
is the offset of label
, which is an immediate value. So you're looking at two different things: getting the value stored at a particular address, versus getting the address itself.
I don't know what the GAS syntax would be to get the moffs64
variant, but with NASM you could write mov rax,[qword label]
(note that this encoding would be longer than if you had simply written mov rax,[label]
- i.e. mov r64, r/m64
).
Upvotes: 3