Re: C/C++ Calling assembler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2009-05-01 at 09:28 -0400, John Fine wrote:

> > An examination of the assembler produced always shows it passes the buffer
> > pointer in %edi and not on the stack.
> >   
> ?? %edi not %rdi ??
> 
> That would mean you are compiling 32 bit code.  I assume that is not 
> what you intended.
> 
> But possibly with a statically allocated buffer, the compiler can deduce 
> that the buffer will be in the first 4GB at run time and it can put the 
> correct address into rdi more efficiently by moving it to edi (with 
> implicit zeroing of the high 32  bits) than by moving it to rdi.

Yes, apparently the compiler does this. It will, for example, put
constants like text messages in a "small memory" area and pass the
address in the 32-bit portion of the register. Because changing the
32-bit portion of the register always zeros the high-order 32 bits, this
results in a correct 64-bit address. The main saving here is that the
instruction to access edi does not require a REX prefix byte, but rdi
does.

Aside: changing 8 or 16 bits in a register does NOT affect the other
portions of the register.

Bob



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux