Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
321 Views

edx and rdx on 64-bit machine

Hi,
I have questions regarding the usage of edx and rdx registers on a 64-bit machine. How these two registers relate to each other? For example, if I want to do subtraction:

sub edx, 16

This instruction subtracts 16 from edx, and it seems the value in rdx would also be subtracted by 16. Why?

Also, when I use gdb and try to print out the value inside edx, it always shows "void". Is there a way to see the content inside edx register on 64-bit machine? Any comments or answers are highly appreciated. Thank you in advance!

Best,

Ivan

0 Kudos
3 Replies
Highlighted
New Contributor II
321 Views

edx is the lower 32 bit of rdx, when you do sub edx,16 the lower 32 bits are subtracted by 16, while the upper 32 bit are zeroed
0 Kudos
Highlighted
Beginner
321 Views

Thank you for the response! What if I do "sub rdx, 16" on a 64-bit machine. Does this keep the value in eax unchange and subtract 16 from rdx?
Thanks,
Ivan
0 Kudos
Highlighted
321 Views

Think of

union
{
struct
{
__int32 eax;
__int32 padd;
};
__int64 rax;
}; // eax and rax share same register, eax is low part of that register

*** however
some operations on eax bung up padd (as intended)

This mapping is like

al is to ax, al is to eax, al is to rax
ax is to eax, ax is to rax
eax is to rax

with rax though there are some rules as to what happens to upper bits of 64-bit register
(sign extend)
(zero extend)
(untouched)
(unknown)

Jim Dempsey


0 Kudos