x86部分寄存器的用法 [英] x86 partial register usage

查看:107
本文介绍了x86部分寄存器的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我保存一个值,假设在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中,并且DHDL仍将具有自己的值,或者现在将具有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?

推荐答案

DLDX的最低有效字节,而DHDX的最高有效字节.反过来,DXEDX的最低有效字.

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

如您所见,您可以写入DLDH,而不会彼此影响(但是您仍在影响DXEDX).

As you can see, you can write to DL or DH without them affecting one another (but you're still affecting DX and EDX).

还可以将值7保存在EDX中,并且DHDL仍将具有自己的值,或者现在将具有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?

从上面的示例可以得出,DH的值为0,DL的值为7.

As you can deduce from my examples above, DH would get the value 0 andDL the value 7.

这篇关于x86部分寄存器的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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