🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.cray
Article #123

getting value of B02 from C

#123
From: Luigi Semenzato
Date: Thu, 27 Aug 1992 00:32
26 lines
1049 bytes
Easy question:

What's the easiest way of getting the address of the
current stack frame from a C procedure?

One rather unreliable way is the following:

	f()
	{
	    int x[1];
	    int *frame = x - 12;
	    ...
	}

The 12 could be a different number and needs to be
hand-tuned every time the body of f changes.  Bleah.

It would be nice to do it with a call to an assembly
language routine.  But it's not trivial, because there
could be a call to the stack overflow handler between
f and the assembly language routine.

Can it be done using inline assembly with `asm'? 
And if yes, how?

My eternal gratitude in advance.  --Luigi
Technical Details
Message-ID: <17h7riINNdki@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!paris.CS.Berkeley.EDU!luigi

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!paris.CS.Berkeley.EDU!luigi
From: luigi@paris.CS.Berkeley.EDU (Luigi Semenzato)
Newsgroups: comp.unix.cray
Subject: getting value of B02 from C
Date: 27 Aug 1992 00:32:50 GMT
Organization: University of California, Berkeley
Lines: 26
Distribution: world
Message-ID: <17h7riINNdki@agate.berkeley.edu>
NNTP-Posting-Host: paris.cs.berkeley.edu