x86 中的重复前缀和强制前缀
在我为特定于 x86 arch 的 Linux 编写一个小型反汇编程序的过程中,我遇到了一个小问题。这是关于强制前缀和重复前缀的。查看Intel文档[1],据说重复前缀是0xf2或0xf3,强制前缀是0x66、0xf2 或 0xf3。
有两条指令具有以下基本操作码:
crc32 -- f2 0f 38 f0(这里,0xf2 是强制前缀)
movbe -- 0f 38 f0
因此,只要计数器寄存器非零,就必须重复的“movbe”指令的操作码应该是:
repnz movbe == f2 0f 38 f0
当我开始反汇编指令时,如果我看到字节 0xf2,我怎么知道它是 的强制前缀crc32 指令,但不是 movbe 指令的重复前缀,反之亦然?我应该将操作码模式 "f2 0f 38 f0" 与哪条指令相匹配?
我缺少什么?
[1] http://www.intel.com/design/intarch/manuals/ 243191.HTM
谢谢和问候,
赫里希凯什穆拉里
In my quest of writing a small disassembler for linux specific to x86 arch, I'm faced with a small issue. It's with regard to mandatory prefixes and repeat prefixes. Looking at the Intel docs [1], it's said that repeat prefixes are 0xf2 or 0xf3, and mandatory prefixes are 0x66, 0xf2 or 0xf3.
There are two instructions which have the following base opcodes:
crc32 -- f2 0f 38 f0 (Here, 0xf2 is a mandatory prefix)
movbe -- 0f 38 f0
So, the opcodes of a 'movbe' instruction which has to repeat as long as the counter register is non-zero should be:
repnz movbe == f2 0f 38 f0
When I start disassembling an instruction, if I see the byte 0xf2, how do I know that it's a mandatory prefix for the crc32 instruction but not a repeat prefix for the movbe instruction, or vice-versa? Which instruction do I match the opcode pattern "f2 0f 38 f0" to?
What am I missing?
[1] http://www.intel.com/design/intarch/manuals/243191.HTM
Thanks and Regards,
Hrishikesh Murali
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只能将重复前缀与字符串指令一起使用(请参阅手册)。 “f2 0f 38 f0”始终是 CRC32 指令。
You can use the repeat prefixes only with string instructions (see the manual). "f2 0f 38 f0" is always CRC32 instruction.
MOVBE
,(在内存中移至/移自大端) ,不是可通过REP((N)E)
前缀重复的指令。只有
字符串指令
可以这样重复。它们是:MOVS*
、LODS*
、STOS*
、SCAS*
、CMPS*、
INS*
、OUTS*
,其中*
为B
、W
code>、D
或Q
(除了INS* 和 OUTS*,最多只能达到双字,不能达到四字)。Intel 的
rep
手动输入 /rep(n)e
解释了这一点。MOVBE
, (move to/from big-endian in memory), is not an instruction repeatable through aREP((N)E)
prefix.Only
string instructions
are repeatable that way. Those are:MOVS*
,LODS*
,STOS*
,SCAS*
,CMPS*
,INS*
,OUTS*
, where*
is either ofB
,W
,D
orQ
(except INS* and OUTS*, which only go up to double words, not quad words).Intel's manual entry for
rep
/rep(n)e
explains that.