Intel x64 指令 CMPSB/CMPSW/CMPSD/CMPSQ [英] Intel x64 instructions CMPSB/CMPSW/CMPSD/CMPSQ
问题描述
这些说明位于英特尔手册的第 558 页.我明白了一般的想法,但我坚持这些指令的确切编码.以上是我的理解,如有不对请指正.这都是 64 位模式.
These instructions are on page 558 of the intel manual. I get the general idea but I'm stuck on the exact encdoding of these instructions. Here is what I understand, please correct me if I'm wrong. This is all in 64-bit mode.
Opcode - Instruction:
A6 - compare byte at address RSI with byte at address RDI
67 A6 - compare byte at address ESI with byte at address EDI
66 A7 - compare word at address RSI with word at address RDI
67 66 A7 - compare word at address ESI with word at address EDI
A7 - compare dword at address RSI with dword at address RDI
67 A7 - compare dword at address ESI with dword at address EDI
REX.W A7 - Compares quadword at address RSI with quadword at address RDI
67 REX.W A7 - Compares quadword at address ESI with quadword at address EDI
推荐答案
说到这些指令的用途,我们必须意识到它们帮助程序员自动化字符串(在连续内存元素的意义上)比较,因此三件事是完成
Speaking of what those instructions are for, one must realize that they help a programmer automatize string (in the meaning of consecutive memory elements) comparison so that three things are done
比较两个内存位置,单条
cmp
指令无法完成
比较影响标志,以便您可以在下一条指令中检查结果,或者只使用 rep
/repnz
前缀来循环,除非某个特定条件不满足.
Comparison affecting flags, so that you can check the result right in the next instruction, or just use the rep
/repnz
prefix to loop unless a certain condition is not met.
根据DF
对两个源操作数进行递增/递减,否则至少需要两个inc
/dec
或 add
/sub
指令,后者需要对超过一个字节的操作
Incrementation/Decrementation of both source operands according to DF
, which would otherwise have to be done by at least two inc
/dec
or add
/sub
instructions, with the latter required for operations on more that just one byte
您还对指令编码表现出了一些兴趣.首先,cmpsx
指令可以用两种方式编码 - 有或没有指定的操作数.这可能特别有用,尽管有一些限制.
You've also shown some interest in instruction encoding. In the first place, cmpsx
instructions can be encoded in two ways - with or without specified operands. This may be particularly useful, although there are some limitations.
其他东西只是在玩前缀字节.关于这一点,请注意,您可以使用段覆盖前缀覆盖第一个源操作数的段,但不能将 es
覆盖为第二个操作数的段.
Other things are just playing with prefix bytes. Onto this just note, that you can override the segment of the first source operand using the segment override prefix, but you can't override the es
as the segment of the second operand.
这篇关于Intel x64 指令 CMPSB/CMPSW/CMPSD/CMPSQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!