16位汇编:无法取消引用某些寄存器 [英] 16-bit Assembly: cannot deref some registers

查看:93
本文介绍了16位汇编:无法取消引用某些寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以下英特尔16位指令:

I'm trying the following Intel 16 bit instruction:

mov si, word [reg]

其中reg是一些寄存器.如果regbx,则可以正常编译,但是当它是axcxdx时,则可以编译.我正在使用NASM作为我的汇编器.我确定这是由于指令集中的某些限制所致.有人可以解释一下限制及其背后的原理吗?

where reg is some register. It compiles fine if reg is bx, but does not when it is ax, cx or dx. I'm using NASM as my assembler. I'm sure this due to some restrictions in the instruction set. Can some one please explain the restriction and the rationale behind it?

推荐答案

仅以下索引寄存器可用于16位寻址模式:

Only the following index registers can be used with 16 bit addressing modes:

bx
si
di
bp
bx + si
bx + di
bp + si
bp + di

同样,SIB寻址在16位寻址模式下不可用.

Likewise, SIB addressing is not available with 16 bit addressing modes.

如果要使用其他索引寄存器,则始终可以使用32位寻址模式,例如[eax].只要您在80386或更高版本的处理器上运行代码,此方法就起作用.

If you want to use other index registers, you can always use a 32 bit addressing mode, e.g. [eax]. This works as long as you run your code on an 80386 or newer processor.

之所以存在此限制,是因为modr/m字节的(索引)寄存器只有3位.正如您在上面看到的那样,确切存在8种可能的索引寄存器组合.我不知道他们为什么要设计这样的寻址模式,但是对于80年代的80位16位处理器来说,这听起来很合理.

This restriction exists because the modr/m byte only has three bits for the (index) register. As you can see above, exactly 8 possible index register combinations exist. I don't know why they designed the addressing modes to be like that, but it sounds pretty reasonable for a 70's era 16 bit processor as the 8086 is.

在32位模式和长模式下,此方案已更改,因此8个可能的索引寄存器中的7个引用了eax,ebx,ecx,edx,esi,edi和ebp,而用esp表示存在一个sib字节,允许使用众所周知的[base+index*scale]寻址模式.

In 32 bit mode and long mode, this scheme was changed so 7 of the 8 possible index registers refer to eax, ebx, ecx, edx, esi, edi, and ebp while what would refer to esp instead indicates the presence of a sib byte allowing for the well known [base+index*scale] addressing modes.

这篇关于16位汇编:无法取消引用某些寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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