From: Bob Plantz <plantz@cds1.net>
To: John Fine <johnsfine@verizon.net>
Cc: gcc-help@gcc.gnu.org, Michael <michael.yacc@blueyonder.co.uk>
Subject: Re: C/C++ Calling assembler
Date: Fri, 01 May 2009 15:47:00 -0000 [thread overview]
Message-ID: <1241192801.3681.9.camel@bob-desktop> (raw)
In-Reply-To: <49FAF90B.5070202@verizon.net>
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
prev parent reply other threads:[~2009-05-01 15:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-30 20:46 Michael
2009-05-01 13:28 ` John Fine
2009-05-01 15:47 ` Bob Plantz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1241192801.3681.9.camel@bob-desktop \
--to=plantz@cds1.net \
--cc=gcc-help@gcc.gnu.org \
--cc=johnsfine@verizon.net \
--cc=michael.yacc@blueyonder.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).