register variables

Chris Torek chris at umcp-cs.UUCP
Fri Jun 21 12:14:06 AEST 1985


> From: shekita at crystal.UUCP

> When is it appropriate to declare a variable as a register? I have
> been told that declaring a variable as a register can actually
> result in slower code. Is there a rule of thumb dictating when and
> when not to declare a variable as a register?

Declare things registers when they're heavily used.  You *can* make
code run slower; consider how long it takes to save and restore the
register(s) before using them for something trivial.

> How many variables can be declared as registers on a Vax 780? In
> general, is there some way to tell how many register variables can
> be declared?

Depends on the compiler.  Most Unix compilers have 6 registers on
Vaxen (r11-r6).  VMS uses r12-r2 (!), though I don't know how their
compiler reacts to register declarations.  Sun's C compiler has 4
register pointers (a5-a2) and 6 register integers (d7-d2).  (I think.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at maryland



More information about the Comp.lang.c mailing list