From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!s28g2000prb.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Mon, 7 Feb 2011 17:06:06 -0800 (PST) Organization: http://groups.google.com Message-ID: <1b09d105-4a3a-434c-9067-d85580b3c8be@s28g2000prb.googlegroups.com> References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <31c357bd-c8dc-4583-a454-86d9c579e5f4@m13g2000yqb.googlegroups.com> <05a3673e-fb97-449c-94ed-1139eb085c32@x1g2000yqb.googlegroups.com> <8r86vgFc3uU1@mid.individual.net> <19fh1chm74f9.11cws0j5bckze.dlg@40tude.net> <5d9bd120-4953-4fb1-a890-27267245e954@8g2000prt.googlegroups.com> <883b7161-15ee-4874-95bb-2e0273dab51d@y36g2000pra.googlegroups.com> <8r9iboFkfvU1@mid.individual.net> <14246472-9488-488a-8720-77b85b91707c@d23g2000prj.googlegroups.com> <8r9ouqFselU1@mid.individual.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1297127167 3955 127.0.0.1 (8 Feb 2011 01:06:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 8 Feb 2011 01:06:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s28g2000prb.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:16959 Date: 2011-02-07T17:06:06-08:00 List-Id: On Feb 7, 1:54=A0pm, "Randy Brukardt" wrote: > "Simon Clubley" wrote in > messagenews:iiopbr$bs7$1@news.eternal-september.org... > ... > > > I realised after posting, this was open to confusion by people who had = not > > encountered this before so a more detailed example follows. The word > > constant > > above does not refer to a programmer defined constant, but a compiler > > defined > > constant. > > You mean a numeric literal (to use the Ada terms). > > > In the statement: > > > c =3D (4 * i) + 2 > > > the compiler would allocate memory locations containing the values 4 an= d > > 2. > > These memory locations would then be used in the generated code wheneve= r > > the > > values of 2 or 4 were found. In other words, all access, including > > literals, > > was by reference. > > > This was a long time ago however. > > Must have been. I remember hearing this story in college. And it supposel= y > was old then. I've always thought of it as a sort of urban legend. But I > suspect that it has more to do with the instruction set of the target > machine. On the Intel architectures that I've worked on my entire working > life, it wouldn't make sense to have a global memory location holding a > literal (the literals can be folded into instructions at very little cost= ). > But I can imagine cases where that wouldn't be true. I think C was originally designed for the PDP-11. It's been ages since I did anything with that processor, but my recollection is that you could include a 16-bit numeric literal in an instruction. It would take up an extra word, but putting the literal somewhere else and including the address in the instruction would also take up an extra word, so you wouldn't save anything. However, if the literal needed to be 32 bits then I can imagine it might have made sense to stick it in a global. -- Adam