编码 8 位操作数大小?是否有类似 16 位的前缀? [英] Encoding 8-bit operand size? Is there a prefix for that like for 16-bit?
问题描述
在指令编码中默认大小为:
In instruction encoding Default sizes are:
operand size is 32 bit
address size is 64 bit
我们可以使用旧前缀:
0x66 – Operand-size override prefix
使操作数大小为 16.如果我想使其为 8 位而不是 16 位怎么办?
to make operand size 16. What if I want to make it 8 bits not 16?
推荐答案
如果我想把它变成 8 位而不是 16 位怎么办?
What if I want to make it 8 bits not 16?
你不能用前缀来做到这一点.支持 8 位操作数大小的指令使用完全独立的操作码,而不是覆盖前缀.
You can't do this with prefixes. Instructions that support an 8-bit operand size do so with an entirely separate opcode, not with an override prefix.
例如:
0: 01 d9 addl %ebx,%ecx
2: 66 01 d9 addw %bx,%cx
5: 00 d9 addb %bl,%cl
32位add
是操作码01
,其中一个mod/rm字节为d9
.16 位加法是相同的,但带有 66
操作数大小前缀.然而,8 位加法是操作码 00
.
The 32-bit add
is opcode 01
, with a mod/rm byte of d9
. The 16-bit add is identical but with the 66
operand size prefix. However the 8-bit add is opcode 00
instead.
对此的解释是历史性的.16 位 8086 CPU 支持 8 位和 16 位操作数,并为两者使用单独的操作码:00
用于 addb
和 01
对于 addw
.(这仍然是您在实模式下运行现代芯片时得到的结果,例如在引导扇区中.)32 位 80386 希望添加 32 位操作数,同时仍支持 8 和 16,但没有空间如此多的操作码,因此对于 32 位保护模式,他们将所有以前的 16 位指令改为 32 位,并且可以覆盖以返回到 16 位,并且他们单独留下了 8 位指令.(在实模式下,操作数大小覆盖具有相反的效果:01
是 addw
而 66 01
是 addl
.)
The explanation for this is historical. The 16-bit 8086 CPU supported 8-bit and 16-bit operands, and used separate opcodes for the two: 00
for addb
and 01
for addw
. (This is still what you get when you run a modern chip in real mode, like in a boot sector.) The 32-bit 80386 wanted to add 32-bit operands while still supporting both 8 and 16, but there was no room for so many more opcodes, so for 32-bit protected mode they made all the formerly 16-bit instructions act as 32-bit instead, with an override available to go back to 16 bit, and they left the 8-bit instructions alone. (In real mode the operand size override has the opposite effect: 01
is addw
and 66 01
is addl
.)
这篇关于编码 8 位操作数大小?是否有类似 16 位的前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!