从 64 位地址加载到其他寄存器而不是 rax [英] Load from a 64-bit address into other register than rax

查看:41
本文介绍了从 64 位地址加载到其他寄存器而不是 rax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 x64 上,从 64 位绝对地址加载(即取消引用 64 位立即数)可以通过

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

movabs addr64, %rax

但是,当目标寄存器不是 rax 时,汇编器会给出一条错误消息,指出 movabs 的操作数大小不匹配.我错过了什么?

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?

推荐答案

来自MOV说明文档您可以看到您可以将 64 位立即移动到任何寄存器,但加载/存储涉及 64 位立即绝对地址 只能与 Areg 一起使用

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

<头>
操作码说明说明
A0MOV AL,moffs8*将 (seg:offset) 处的字节移动到 AL.
REX.W + A0MOV AL,moffs8*将 (offset) 处的字节移动到 AL.
A1MOV AX,moffs16*将 (seg:offset) 处的单词移至 AX.
A1MOV EAX,moffs32*将 (seg:offset) 处的双字移动到 EAX.
REX.W + A1MOV RAX,moffs64*将位于 (offset) 处的四字移动到 RAX.
A2MOV moffs8,AL将 AL 移动到 (seg:offset).
REX.W + A2MOV moffs8***,AL将 AL 移动到 (偏移).
A3MOV moffs16*,AX将 AX 移动到 (seg:offset).
A3MOV moffs32*,EAX将 EAX 移动到 (seg:offset).
REX.W + A3MOV moffs64*,RAX将 RAX 移动到(偏移量).
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).

如您所见,没有用于对寄存器编号进行编码的 ModR/M 字节.由于这比将 64 位立即数移动到寄存器更不常用,因此不会有问题.如果确实需要,可以在 2 条指令中完成

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

MOVABSMOV 操作码形式 MOV Areg, [Offs64]MOV [Offs64] 的 GAS 操作码名称,注册.在 Yasm 的 NASM 语法模式下,你可以通过说 MOV AX, [qword xxx] 来获得这种形式.Yasm 的 GAS 语法模式接受 MOVABS(为了 GAS 兼容性).请注意,此表格仅适用于以 Areg (AL/AX/EAX/RAX) 作为源/目标寄存器的情况.

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

这篇关于从 64 位地址加载到其他寄存器而不是 rax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆