Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.

edx and rdx on 64-bit machine

ivantsou
Beginner
4,033 Views
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
neni
New Contributor II
4,033 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
ivantsou
Beginner
4,033 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
jimdempseyatthecove
Honored Contributor III
4,033 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
Reply