home *** CD-ROM | disk | FTP | other *** search
- Path: 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
-
- 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
-