[net.micro.cbm] C Power -a and -s options

daemon@caip.UUCP (07/14/86)

From: pipedev@NADC

The -a option causes the default storage class for local variables to be
"auto" (this is normally the default in most other C compilers, but not
for C Power, where the default is "register".  Register variables are simu-
lated witha block of page zero "registers".  Since this same block of registers
is shared when functions are called, there is a problem when the address of
a local variable of storage class "register" is passed - the address will
not contain the proper value during execution of the function called).  Using
the -a option makes the generated object code more compatible with other C
compilers, but at quite a cost in execution speed - better you should explicitly
declare the storage class of all local variables (but traditionally, this has
not been done, and often "auto" is assumed).  The -s option causes the default
storage class for local variables to be "static".  Technically, this should
produce code slightly faster than "auto" at the cost of the loss of recursion
capability; in actuality, the "register" default is better than both because
of the page zero accesses.

Summary: Avoid using -a and -s options unless the program just plain doesn't
work and appears like it should - then try the -a option: if the program now
works, the best bet (for speed) is to search out places within the program
where "&var" is either passed as a parameter to another function ("var" is
a local scalar declared without explicit storage class) or stuffed into a
pointer which is subsequently passed to another function.  Simply
declare such variables "auto", then no longer use the -a option, and the problem
will be solved with the program running as fast as possible.  There seems to
be little redeeming value for the -s option.

Frank Prindle
Prindle@NADC.arpa