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
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.
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
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
.
So:
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
As you can see, you can write to DL
or DH
without them affecting one another (but you're still affecting DX
and EDX
).
Also, can you save the value 7 in
EDX
andDH
andDL
would still have their own values or will they now have 7?
As you can deduce from my examples above, DH
would get the value 0 andDL
the value 7.
If you address DH and DL individually, then the values are individually accessible and be kept as long as you don't perform operations which will affect other parts of the register.
For example
EDX------
DX --
DH DL
xor edx, edx ; edx = 0000 00 00
mov 01h, dh ; edx = 0000 01 00
mov 02h, dl ; edx = 0000 01 02
sub dh, dl ; edx = 0000 ff 01 <- Note that this doesn't
; overflow to the high word, because you
; are using only 8 bit registers
mov 80000001, eax
sub edx, eax ; edx = 8000 FF 03 <- Here you will affect
; the whole register, because you address it with 32 bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With