public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Dave Korn" <dave.korn@artimi.com>
To: "'DJ Delorie'" <dj@redhat.com>
Cc: <shreyas76@gmail.com>, <binutils@sources.redhat.com>
Subject: RE: Address assignment
Date: Wed, 14 Sep 2005 19:37:00 -0000	[thread overview]
Message-ID: <SERRANOMJ3G9Vbj2ltp000003d6@SERRANO.CAM.ARTIMI.COM> (raw)
In-Reply-To: <200509141316.j8EDGj2h015594@greed.delorie.com>

----Original Message----
>From: DJ Delorie
>Sent: 14 September 2005 14:17

>>   Ah, you're using a compiler rather than writing assembly?
> 
> You use the compiler to define the structure, and assembly to place
> it.

  I just wanted to suggest an all-in-one-place solution.  There are many
ways to do most things.
  
>>>>         .global _my_struct
>>>> _my_struct = 0xa0001028
>> 
>> you'd want to use a pointer variable:
>> 
>> struct my_struct_type * const my_struct = (struct my_struct_type
>> *)0xa0001028;
> 
> Why add an unneeded level of indirection?  Especially on time-critical
> embedded systems?

  These days, I really have *lots* of faith in the compiler to be able to
optimise that away[*].  But I guess you could always write

#define my_struct (*(struct my_struct_type *)0xa0001028)

and treat it just like an object

   my_struct.x = 3;

    cheers,
      DaveK

[*]   And I tested it as well; with cygwin's x86 gcc-3.4.4, -O0 still loads
the pointer into a register and accesses through it, but at -O1 the pointer
load is eliminated and gcc just emits an absolute memory address in the
instruction.
-- 
Can't think of a witty .sigline today....

  reply	other threads:[~2005-09-14 18:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-14  4:20 shreyas krishnan
2005-09-14  5:38 ` DJ Delorie
2005-09-14 10:47   ` shreyas krishnan
2005-09-14 13:17     ` Dave Korn
2005-09-14 16:50       ` DJ Delorie
2005-09-14 19:37         ` Dave Korn [this message]
2005-09-14 20:53           ` Paul Koning
2005-09-14 21:20             ` Dave Korn
2005-09-14 22:16         ` shreyas krishnan
2005-09-14 19:23           ` DJ Delorie
2005-09-14 23:23       ` shreyas krishnan
2005-09-14 23:43         ` DJ Delorie
2005-09-15  2:23           ` shreyas krishnan

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=SERRANOMJ3G9Vbj2ltp000003d6@SERRANO.CAM.ARTIMI.COM \
    --to=dave.korn@artimi.com \
    --cc=binutils@sources.redhat.com \
    --cc=dj@redhat.com \
    --cc=shreyas76@gmail.com \
    /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).