问题描述
如果我保存一个值,假设在8位寄存器DH
中为10,然后在8位寄存器DL
中另一个值为15.这是可行的还是因为它们都在32位EDX
寄存器中而彼此替代?
If I save a value, let's say 10, in 8 bit register DH
and then another value, 15, in 8 bit register DL
. Would that work or will they override each other since they are both in 32-bit EDX
register?
mov $10, %DH
mov $15, %DL
cmp %DL, %DH
jle done
基本上,当我使用8位寄存器时,我只是感到困惑,它将如何影响32位寄存器,反之亦然.谢谢.
Basically I'm just confused when I'm using the 8 bit register how will it affect the 32 bit register and vice versa.Thanks.
此外,您是否可以将值7保存在EDX
中,并且DH
和DL
仍将具有自己的值,或者现在将具有7?
Also, can you save the value 7 in EDX
and DH
and DL
would still have their own values or will they now have 7?
推荐答案
DL
是DX
的最低有效字节,而DH
是DX
的最高有效字节.反过来,DX
是EDX
的最低有效字.
DL
is the least significant byte of DX
, and DH
is the most significant byte of DX
. DX
in turn is the least significant word of EDX
.
所以:
MOV EDX,0x12345678
; Now EDX = 0x12345678, DX = 0x5678, DH = 0x56, DL = 0x78
MOV DL,0x01
; Now EDX = 0x12345601, DX = 0x5601, DH = 0x56, DL = 0x01
MOV DH,0x99
; Now EDX = 0x12349901, DX = 0x9901, DH = 0x99, DL = 0x01
MOV DX,0x1020
; Now EDX = 0x12341020, DX = 0x1020, DH = 0x10, DL = 0x20
如您所见,您可以写入DL
或DH
,而不会彼此影响(但是您仍在影响DX
和EDX
).
As you can see, you can write to DL
or DH
without them affecting one another (but you're still affecting DX
and EDX
).
从上面的示例可以得出,DH
的值为0,DL
的值为7.
As you can deduce from my examples above, DH
would get the value 0 andDL
the value 7.
这篇关于x86部分寄存器的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!