什么是速度快:JMP或NOP指令的字符串? [英] What is faster: JMP or string of NOPs?

查看:521
本文介绍了什么是速度快:JMP或NOP指令的字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现二进制翻译和必须处理的NOP(0×90),长度约16运codeS的序列。它是更好的性能在这样的序列开始放置JMP(为末)?

I'm implementing binary translation and have to deal with sequences of NOPs (0x90) with length about 16 opcodes. Is it better for performance to place JMP (to the end) at start of such sequences?

推荐答案

借助英特尔架构软件开发人员指南, 2B卷(说明NZ)包含下表(第4-12)关于 NOP

The Intel Architecture Software developer's guide, volume 2B (instructions N-Z) contains the following table (pg 4-12) about NOP:

表4-9。 NOP指令的推荐的多字节序列


Length    Assembly                                   Byte Sequence
=================================================================================
2 bytes   66 NOP                                     66 90H
3 bytes   NOP DWORD ptr [EAX]                        0F 1F 00H
4 bytes   NOP DWORD ptr [EAX + 00H]                  0F 1F 40 00H
5 bytes   NOP DWORD ptr [EAX + EAX*1 + 00H]          0F 1F 44 00 00H
6 bytes   66 NOP DWORD ptr [EAX + EAX*1 + 00H]       66 0F 1F 44 00 00H
7 bytes   NOP DWORD ptr [EAX + 00000000H]            0F 1F 80 00 00 00 00H
8 bytes   NOP DWORD ptr [EAX + EAX*1 + 00000000H]    0F 1F 84 00 00 00 00 00H
9 bytes   66 NOP DWORD ptr [EAX + EAX*1 + 00000000H] 66 0F 1F 84 00 00 00 00 00H

这可以构建一定规模的填充 NOP 。随着其中的两个,你可以弥合的16字节,虽然我第二个建议,检查指导优化(对于您所指定的CPU)是否 JMP 是不是两个快例如 NOP指令

This allows you to construct "padding NOP" of certain sizes. With two of those, you can bridge 16 Bytes, although I second the suggestion to check the optimization guides (for the CPU you're targeting) whether a JMP is faster than two such NOPs.

这篇关于什么是速度快:JMP或NOP指令的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆