指令长度 [英] Instruction Lengths
问题描述
我在看汇编中的不同指令,对如何确定不同操作数和操作码的长度感到困惑.
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?
例如:
push %ebp ; takes up one byte
mov %esp, %ebp ; takes up two bytes
所以问题是:
看到给定的指令后,如何推断其操作码需要多少字节?
Upon seeing a given instruction, how can I deduce how many bytes its opcode will require?
推荐答案
在没有数据库的情况下,x86没有硬性规定,因为指令编码非常复杂(操作码本身可以在1到3个字节之间变化).您可以查阅英特尔®64和IA-32架构软件开发人员手册2A 文档(第2章:指令格式),以了解如何对指令及其操作数进行编码:
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:
这篇关于指令长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!