简体   繁体   English

8086汇编寄存器间接MOV指令

[英]8086 assembly register indirect MOV instruction

I just wanted to ask: why is it that when I write : 我只是想问:为什么我写的时候:

MOV DL, [BX] 

it works, but when I write: 它有效,但是当我写:

MOV DL, [AX]

it doesn't? 不是吗

In the current Intel® 64 and IA-32 Architectures Software Developer Manual this is described on page 509 of 4898: 在当前的英特尔®64和IA-32体系结构软件开发人员手册中,第4898页的第509页对此进行了描述:

In 16-bit Intel assembly it is impossible to use the AX register for register indirect addressing. 在16位Intel汇编中,不可能使用AX寄存器进行寄存器间接寻址。

As you can see in the manual, you can use the following registers for indirect addressing ; 正如您在手册中所看到的,可以使用以下寄存器进行间接寻址 for all of the following registers there are addressing modes that use them on their own (or in base+index pairs): 对于以下所有寄存器,有一些寻址模式可以单独使用它们(或以基址+索引对使用):

BX, BP, SI, DI BX,BP,SI,DI

These can be combined to (with optional displacements) 这些可以组合为(具有可选的位移)

 [BX+SI]    [BX+SI]+disp8    [BX+SI]+disp16
 [BX+DI]    [BX+DI]+disp8    [BX+DI]+disp16
 [BP+SI]    [BP+SI]+disp8    [BP+SI]+disp16
 [BP+DI]    [BP+DI]+disp8    [BP+DI]+disp16
 [SI]          [SI]+disp8       [SI]+disp16
 [DI]          [DI]+disp8       [DI]+disp16
 disp16        [BP]+disp8       [BP]+disp16
 [BX]          [BX]+disp8       [BX]+disp16

Hence your first instruction (expanded) 因此,您的第一条指令(扩展的)

MOV DL, BYTE PTR [BX] 

is valid, but your second one isn't, because in the 8086 (x86_16) ISA there is no ModRM addressing-mode encoding for it in x86 machine code. 是有效的,但第二个无效,因为在8086(x86_16)ISA中,在x86机器代码中没有针对它的ModRM寻址模式编码。


32-bit and 64-bit addressing modes use a different encoding for addressing modes, with an optional SIB (scale+index+base) byte that allows nearly any combination of base and index (except index=RSP), and with a 2-bit shift count (scale factor) for the index. 32位和64位寻址模式对寻址模式使用不同的编码,具有可选的SIB(标度+索引+基数)字节,该字节几乎允许基数和索引的任何组合(索引= RSP除外),并带有2-索引的移位计数(比例因子)。 See Referencing the contents of a memory location. 请参阅引用内存位置的内容。 (x86 addressing modes) or the other tables in Intel's manual. (x86寻址模式)或Intel手册中的其他表格。

mov DL, [EAX] is valid even in 16-bit mode , but only on 386-compatible CPUs. mov DL, [EAX]即使在16位模式下也有效 ,但仅在386兼容CPU上有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM