如何判断 x86 指令的长度? [英] How to tell the length of an x86 instruction?
问题描述
我正在查看汇编中的不同指令,但我对如何决定不同操作数和操作码的长度感到困惑.
这是您应该从经验中知道的,还是有办法找出哪个操作数/运算符组合占用了多少字节?
例如:
push %ebp ;占用一个字节mov %esp, %ebp ;占用两个字节
所以问题是:
看到给定的指令后,我如何推断其操作码需要多少字节?
没有数据库的 x86 没有硬性规定,因为指令编码非常复杂(并且操作码本身可以从 1 到 3 个字节不等).您可以查阅
I was looking at the different instructions in assembly and I am confused on how the lengths of different operands and opcodes are decided upon.
Is it something you ought to know from experience, or is there a way to find out which operand/operator combination takes up how many bytes?
For eg:
push %ebp ; takes up one byte
mov %esp, %ebp ; takes up two bytes
So the question is:
Upon seeing a given instruction, how can I deduce how many bytes its opcode will require?
There's no hard and fast rule for x86 without a database as the instruction encoding is pretty complex (and the opcode itself can vary from 1 to 3 bytes). You can consult the Intel® 64 and IA-32 Architectures Software Developer’s Manual 2A document (Chapter 2: Instruction Format) to see how instructions and their operands are encoded:
这篇关于如何判断 x86 指令的长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!