edx and rdx on 64-bit machine

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!



4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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

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

Think of

__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)

Jim Dempsey

Leave a Comment

Please sign in to add a comment. Not a member? Join today