- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page