x64指令编码和ModRM字节 [英] x64 instruction encoding and the ModRM byte
问题描述
call qword ptr [rax]
call qword ptr [rcx]
是
FF 10
FF 11
我可以看到最后一位数字(0/1)在哪里来自(寄存器编号),但是我试图找出倒数第二个数字(1)的来源。根据 AMD64体系结构程序员手册第3卷:通用和系统说明第56页,
I can see where the last digit (0/1) comes from (the register number), but I'm trying to figure out where the second last digit (1) comes from. According to AMD64 Architecture Programmer’s Manual Volume 3: General-Purpose and System Instructions page 56,
/ digit-指示ModRM字节指定仅一个寄存器或内存(r / m)操作数。该数字由ModRM reg字段指定,并用作指令操作码扩展。有效数字值的范围为0到7。
"/digit - Indicates that the ModRM byte specifies only one register or memory (r/m) operand. The digit is specified by the ModRM reg field and is used as an instruction-opcode extension. Valid digit values range from 0 to 7."
等效的英特尔文档说了类似的内容,并且通过寄存器的调用
被指定为
The equivalent Intel document says something similar, and call
via a register is specified to be encoded as
FF /2
并且...我有不知道这是什么意思,也不知道规范中的2如何连接到最终结果中的高1位。
and... I have no idea what that means, or how the 2 in the specification connects to the high 1 digit in the end result. Is there a differently worded explanation available anywhere?
推荐答案
ModR / M字节有3个字段:
The ModR/M byte has 3 fields:
bit 7 & bit 6 = mod
bit 5 through bit 3 = reg = /digit
bit 2 through bit 0 = r/m
这在中如图2-1所示。第64卷的英特尔64和IA-32架构指令格式
。 英特尔®64和IA-32体系结构软件开发人员手册的2A
。
所以,有:
0x10
= 00.010.000
(mod = 0 , reg / digit = 2
, r / m = 0
)
0x10
= 00.010.000
(mod=0, reg/digit=2
, r/m=0
)
和
0x11
= 00.010.001
(mod = 0, reg / digit = 2
, r / m = 1
)。
0x11
= 00.010.001
(mod=0, reg/digit=2
, r/m=1
).
这篇关于x64指令编码和ModRM字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!