[comp.sys.mac.programmer] MPW C & registers

dorner@pequod.cso.uiuc.edu (Steve Dorner) (12/07/89)

SADE is capable of examining variables in previous stack frames, but not if
those variables are in registers.  Therefore, I'd like to be able to tell the
MPW C compiler to not put variables in registers when I'm compiling test
versions of things.

I realize there are a number of kludgy ways to keep specific variables
out of registers.  What I want is a simple switch to keep all variables out
of registers.

After looking at the index, the Compiler Options section, and the Language
section of the MPW C 3.0 manual, I have not found such an option.  Does one
exist?  If not, why not?  It sure would be useful, and I wouldn't think it
would be hard to do.

-- 
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: {convex,uunet}!uiucuxc!dorner
IfUMust:  (217) 244-1765

beard@ux1.lbl.gov (Patrick C Beard) (12/08/89)

In article <1989Dec6.211341.762@ux1.cso.uiuc.edu> dorner@pequod.cso.uiuc.edu (Steve Dorner) writes:
>SADE is capable of examining variables in previous stack frames, but not if
>those variables are in registers.  Therefore, I'd like to be able to tell the
>MPW C compiler to not put variables in registers when I'm compiling test
>versions of things.
>

I suppose a #pragma directive might be a nice way to do it as well, but you
can keep variables out of registers by taking their addresses:  i.e. statements
like

foo()
{
	int x, y, z;
	&x, &y, &z;	// keep these suckers out of registers.
	...
}

will keep them on the stack.  

After looking in my MPW C manual, I also see that the keyword volatile can
be used to keep variables on the stack.  See the manual, pg. 48.


-------------------------------------------------------------------------------
-  Patrick Beard, Macintosh Programmer                        (beard@lbl.gov) -
-  Berkeley Systems, Inc.  ".......<dead air>.......Good day!" - Paul Harvey  -
-------------------------------------------------------------------------------