Re: A89: Other storage class modifiers - register
[Prev][Next][Index][Thread]
Re: A89: Other storage class modifiers - register
----- Original Message -----
From: Zeljko Juric <zjuric@utic.net.ba>
To: <assembly-89@lists.ticalc.org>
Sent: Saturday, April 08, 2000 3:34 PM
Subject: Re: A89: Other storage class modifiers
> > Concerning "register", I don't think it should be used nowadays, since
> > modern compilers like GCC are efficients enough to make this choice as
> > required.
>
> There is still one need for "register". Inteligent compilers like GCC
> really allocated as many possible vars in registers. But look the
> following example:
>
> int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t;
>
> Of course, all of them can not be in registers, because there is not
> enough registers. The compiler will allocate some of them in registers
> in according to his "estimation". But, if you want, for any reason,
> that p,q and r MUST be in registers, use:
>
> int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,s,t;
> register int p,q,r;
>
> Zeljko Juric
>
I agree with the above completely, I would just like to add one thing
though. The register modifier is a _request_ to the compiler. The reason for
this is simple - there are only so many registers to use, therefore you
couldn't have 500 register variables. Therefore, p, q, and r may still not
end up in registers.
When the register modifier was first defined in the C language the type char
and int were the only types supported. When C was standardized a decision
was made to expand the definition of register. The ANSI standard states the
register modifier may be applied to _any_ data type to create the var in the
way that it may be accessed as fast as possible. For int and char this still
means putting them in cpu registers, however as I stated above, the
compiler is free to ignore this completely.
I do not, however, know to what extent tigcc complies with this - gcc is
well known for having extra little features (as I am sure you are aware).
- Byron De Vries
webmaster@communitycrc.org
References: