是否有已弃用的 x86 指令列表?
我正在参加 x86 汇编语言编程课程,并且知道某些指令不应再使用 - 因为它们在现代处理器上速度很慢;例如循环指令。
我尚未找到任何被视为已弃用且应避免使用的指令列表;任何指导将不胜感激。
I'm taking an x86 assembly language programming class and know that certain instructions shouldn't be used anymore -- because they're slow on modern processors; for example, the loop instruction.
I haven't been able to find any list of instructions that are considered deprecated and should be avoided; any guidance would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您最好的选择是查阅Intel官方优化指南。
您可以在 找到此手册。在这里。
Your best bet is to consult Intel's official optimization guide.
This an other manuals can be found here.
噢,但是使用
loop
指令可能仍然有充分的理由。例如,循环标签
仅需要两个字节。与dec cx
后跟jnz label
不同,需要三个字节。有时代码大小比速度更重要。不过,我建议,如果您刚刚学习 x86 汇编(特别是如果这是您第一次涉足汇编语言),那么您首先要专注于如何做事。一旦你对事情的运作方式有了更好的认识,就可以考虑让它们变得更快。
Oh, but there still might be a good reason to use the
loop
instruction. For example,loop label
only requires two bytes. As opposed todec cx
followed byjnz label
requires three bytes. Sometimes code size is more important than speed.I would suggest, however, that if you're just learning x86 assembly--especially if this is your first foray into assembly language--that you first concentrate on how to do things. Once you've gotten a better feel for how things work, then worry about making them faster.
所有 CPU 指令均 100% 有效,可与旧版 CPU 兼容。那么为什么要避免一些指导呢?没有真正弃用的 x86 指令!但我们可以说:
1)所有字符串指令,如 rep movsb 都比较慢。
2) xlat 速度慢且很少使用。
3)此外,使用堆栈帧函数ENTER 和LEAVE 也很慢。
4)在Windows(XP,vista...)下不推荐使用指令IN和OUT,但仅在CPU环2(应用程序级别)下,int nn也被弃用,除了int3(调试器陷阱) )。
编辑:添加了简单的速度测试来检查不同版本CPU上的字符串指令
rep cmp
。测试是在Delphi IDE下进行的,但asm部分是很容易在任何其他 IDE 中进行翻译。
ArraySize = 50000 的测试
平均结果...
1)我的 Intel 单核 CPU Pentium 4 结果:循环计数:232000;重复刻度数:233000
2)我的 Intel Core 2 四核 CPU 结果:循环刻度数:158000;代表刻度:375000
All CPU instructions are 100% functional to reach compatibility with older CPUs. So why to avoid some instruction? There is no realy deprecated x86 instructions! But we can say:
1)All string istructions like rep movsb are slower.
2) xlat is slow and very rare in use.
3)Also the use of stack frame functions ENTER and LEAVE is slow.
4)Uder Windows (XP, vista...) the deprecated instructions are IN and OUT, but only under CPU ring 2 (aplication level), also the int nn is deprecated, except int3 (debugger trap).
EDIT: added simple speed test to check strings instruction
rep cmp
on different versions of CPUs.Test is made under Delphi IDE but the asm part is very easy to translate in any other IDE.
TESTs for ArraySize = 50000
Average results...
1)My Intel single core CPU Pentium 4 results: Loop ticks : 232000; Rep ticks : 233000
2)My Intel Core 2 Quad CPU results: Loop ticks : 158000; Rep ticks : 375000
如果您想知道要避免什么,请直接联系处理器制造商,英特尔和 AMD 都有其处理器支持的指令集以及支持程度的手册,如果可能是优化量,那么您最好的选择,但如果您唯一的选择刚开始,听从吉姆的建议,先让事情正常运转,然后再担心速度
If you what to know what to avoid, go directly to the processor manufacturers, both intel and amd have manuals for the instruction sets their processors support and to what degree they support them, your best bet if probably the optimization volumes, but if your only just starting out, take Jim's advice, get the thing working first before you worry about speed