&是什么QUOT;代表; NOP;"在x86汇编是什么意思?
- 这是什么
代表; NOP
意思? - 是不是一样的
暂停
指令? - 是不是一样的
代表NOP
(没有分号)? - 有什么区别的简单
NOP
指令? - 是否表现不同的AMD和Intel处理器?
- (奖金)哪里是这些指令的正式文件?
- What does
rep; nop
mean? - Is it the same as
pause
instruction? - Is it the same as
rep nop
(without the semi-colon)? - What's the difference to the simple
nop
instruction? - Does it behave differently on AMD and Intel processors?
- (bonus) Where is the official documentation for these instructions?
在another问题,我意识到,我不知道是什么代表; NOP;
指86(或x86-64的)装配。而且我也不能在网上找到一个很好的解释。
After some discussion in the comments of another question, I realized that I don't know what rep; nop;
means in x86 (or x86-64) assembly. And also I couldn't find a good explanation on the web.
我知道代表
为preFIX那意味着的重复下一条指令 CX
次的(或至少是在旧的16位x86汇编)。根据本summary表在Wikipedia ,似乎代表
只能用 MOVS使用
, STOS
, CMPS
,检出限
,中汽南方
(但也许于新的处理器去掉这个限制)。因此,我认为代表NOP
(没有分号)将重复 NOP
操作 CX
倍。
I know that rep
is a prefix that means "repeat the next instruction cx
times" (or at least it was, in old 16-bit x86 assembly). According to this summary table at Wikipedia, it seems rep
can only be used with movs
, stos
, cmps
, lods
, scas
(but maybe this limitation was removed on newer processors). Thus, I would think rep nop
(without semi-colon) would repeat a nop
operation cx
times.
然而,经过进一步搜索,我更糊涂了。看来,代表; NOP
和暂停
map以完全相同的运算code 和暂停
已经不仅仅是一个有点不同的行为 NOP
。从2005年一些旧邮件说不同的东西:
However, after further searching, I got even more confused. It seems that rep; nop
and pause
map to the exactly same opcode, and pause
has a bit different behavior than just nop
. Some old mail from 2005 said different things:
- 的尽量不要烧得太费电的
- 的就相当于NOP只是2字节编码。的
- 的这是英特尔的法宝。它像NOP,但让其他同级HT运行'的
- 的这是暂停在Intel和快速填充的速龙的
- "try not to burn too much power"
- "it is equivalent to 'nop' just with 2 byte encoding."
- "it is magic on intel. Its like 'nop but let the other HT sibling run'"
- "it is pause on intel and fast padding on Athlon"
使用这些不同的意见,我无法理解的正确含义。
With these different opinions, I couldn't understand the correct meaning.
它在Linux内核中使用(在两个i386和x86_64),与此评论起来: / * REP NOP(暂停)是插入到忙等待循环一件好事* /
也的 /doc.bertos.org/2.6/attr_8h_source.html#l00096\">being使用,同样的评论。
It's being used in Linux kernel (on both i386 and x86_64), together with this comment: /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
It is also being used in BeRTOS, with the same comment.
代表; NOP
确实是一样的暂停
指令(运code F390
) 。它可以用于不支持暂停
指令尚未装配。在previous处理器,这根本不算什么做的,就像 NOP
但在两个字节。在支持超线程的新处理器,它被用作一个提示你正在执行一个SPINLOOP以提高性能的处理器。从英特尔的指令参考:
rep; nop
is indeed the same as the pause
instruction (opcode F390
). It might be used for assemblers which don't support the pause
instruction yet. On previous processors, this was simply did nothing, just like nop
but in two bytes. On new processors which support hyperthreading, it is used as a hint to the processor that you are executing a spinloop to increase performance. From Intel's instruction reference:
提高旋转等待环路的性能。当执行自旋等待循环,奔腾4或英特尔至强处理器遭受退出循环的时候,因为它检测到可能出现的内存才能违规严重的性能损失。暂停指令提供了一个提示,该code序列为自旋等待循环处理器。处理器使用该提示,以避免内存秩序违规在大多数情况下,极大地提高了处理器的性能。出于这个原因,建议一个暂停指令被放置在所有旋转等待环路。
Improves the performance of spin-wait loops. When executing a "spin-wait loop," a Pentium 4 or Intel Xeon processor suffers a severe performance penalty when exiting the loop because it detects a possible memory order violation. The PAUSE instruction provides a hint to the processor that the code sequence is a spin-wait loop. The processor uses this hint to avoid the memory order violation in most situations, which greatly improves processor performance. For this reason, it is recommended that a PAUSE instruction be placed in all spin-wait loops.