[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] RE: [Xen-devel] Definition of eax and rax
> -----Original Message----- > From: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx > [mailto:xen-devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of Li, Xin B > Sent: 13 December 2006 12:13 > To: Keir Fraser > Cc: Xen Development Mailing List > Subject: [Xen-devel] Definition of eax and rax > > Keir, just noticed the macro: > #define __DECL_REG(name) union { uint64_t r ## name, e ## name; } > So, rax and eax are both 64bit, but I think we'd better define eax to > 32bit, how do you think? I believe the purpose of the double-declaration is to have the ability to do generic code that uses eax for both 32- and 64-bit code, avoiding having to write two different pieces of code for 32- and 64-bit code. If you want to use the lower 32-bits of rAX in 64-bit mode, I'd suggest a more explicit way (like casting it to 32-bit size, for exmple). Note also that the x86_64 specification says that a 32-bit write to a 64-bit register should zero-fill the upper 32 bits, which won't happen if you have : union { uint64_t rax; uint32_t eax } rAX; rAX.eax = 7; You'd end up with whatever was there from before in the upper bits of rAX.rax... -- Mats > -Xin > > _______________________________________________ > Xen-devel mailing list > Xen-devel@xxxxxxxxxxxxxxxxxxx > http://lists.xensource.com/xen-devel > > > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |