Xref: utzoo comp.arch:7437 comp.lang.c:14499
Path: utzoo!utgpu!watmath!clyde!att!rutgers!mailrus!ames!killer!elg
From: elg@killer.DALLAS.TX.US (Eric Green)
Newsgroups: comp.arch,comp.lang.c
Subject: Re: The & (address) operator and register allocation
Message-ID: <6303@killer.DALLAS.TX.US>
Date: 3 Dec 88 00:51:12 GMT
References: <1224@cps3xx.UUCP>
Organization: The Unix(R) Connection, Dallas, Texas
Lines: 35

in article <1224@cps3xx.UUCP>, rang@cpsin3.cps.msu.edu (Anton Rang) says:
> have call-by-reference, is it possible to allocate variables which are
> passed by reference into registers?
>   For example, the C code:
> 
> 	scanf("%d", &N);
> 
>   would require that the address of N be taken to read it from the
> standard input.  If I then have a loop:
> 
> 	for (i=0; i 
> would the final program have to read N from memory each time?  

There was a discussion in comp.lang.c about this. There's two ways of
doing this: memory-mapped register set, or "smart" compiler that tries
to optimize register usage, e.g. keeping values in registers as long
as possible, and only dumping them to RAM when necessary for things
like the scanf call above. 
     AMD29000, SPARC, etc. don't have memory-mapped registers, and
thus use at least a semi-intelligent compiler. The Pyramid 90x has
memory-mapped registers. I suspect it's because Pyramid's early "C"
compiler was a bit, err, dumb (their "new" compiler, though, is quite
spiffy, global optimizer and all... I tried hand-tweaking the
assembly-language output once, and for the most part failed to make a
bit of difference).

> | Anton Rang (grad student) | "VMS Forever!"         | "Do worry...be SAD!" |
                                 ^^^^^^^^^^^
                                Gag choke BARF (;-)
--
Eric Lee Green    ..!{ames,decwrl,mit-eddie,osu-cis}!killer!elg
          Snail Mail P.O. Box 92191 Lafayette, LA 70509              
"We have treatments for disturbed persons, Nicholas. But, at least for
the moment, we have no treatment for disturbing persons." -- Dr. Island