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-7-bit Path: g2news2.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe10.iad.POSTED!1d9d5bd3!not-for-mail From: David Thompson Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Message-ID: <1loul6dehbehd41apuojo7bb427angae9g@4ax.com> References: <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> <1b09d105-4a3a-434c-9067-d85580b3c8be@s28g2000prb.googlegroups.com> X-Newsreader: Forte Agent 3.3/32.846 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Mon, 21 Feb 2011 07:17:17 UTC Organization: TeraNews.com Date: Mon, 21 Feb 2011 02:17:37 -0500 Xref: g2news2.google.com comp.lang.ada:18478 Date: 2011-02-21T02:17:37-05:00 List-Id: On Mon, 7 Feb 2011 17:06:06 -0800 (PST), Adam Beneschan wrote: > I think C was originally designed for the PDP-11. It's been ages Yes and no. C was derived from BCPL and B, which were designed for large (or at least medium) word machines. When dmr et al got a PDP-11 it led to enough change in B he decided 'new B' deserved a new name. The PDP-11 architecture certainly influenced a lot of early C code, especially Unix (which is what B and C were created to do), particularly using pointers to step through strings and other arrays rather than subscripting, but it's difficult to see much influence on the language itself. In particular there is a widespread myth that the increment/decrement operators p++ *p++ p-- etc. were created for the autoincrement and autodecrement addressing modes on the -11, but in fact these operators were in B before the -11 even existed AND B and C have the full orthogonal set whereas the -11 has only a few cases, albeit arguably the most useful ones. > 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 Cost not save. Immediate (R7)+ takes one word in the instruction. Somewhere else generally requires either absolute @(R7)+ addr where addr points to data, or relative offset(R7) R7'+offset points to data; both of those have a word in the instruction PLUS the data word. The only exception would be if a register contains a pointer to (exactly) the data word, and since you have (at most) 6 registers to work with they can't simultaneously point to very many things. The decade-subsequent VAX did have a more efficient encoding for short (8bit, or 16bit) offsets from a register, and enough registers you could usually leave one or a few pointed at data areas. > needed to be 32 bits then I can imagine it might have made sense to > stick it in a global. > But as already noted *in Fortran* all arguments were normally passed by reference/address. Strictly the standards didn't require this, and still don't except for some newer special cases, but they did and do require callees to generally be able to mutate actuals, and the simplest implementation was usually to always pass by reference. And to pass by address of course you need a memory location, although not necessarily a static/global one.