home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / cray / 248 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1012 b 

  1. Path: sparky!uunet!stanford.edu!agate!paris.CS.Berkeley.EDU!luigi
  2. From: luigi@paris.CS.Berkeley.EDU (Luigi Semenzato)
  3. Newsgroups: comp.unix.cray
  4. Subject: getting value of B02 from C
  5. Date: 27 Aug 1992 00:32:50 GMT
  6. Organization: University of California, Berkeley
  7. Lines: 26
  8. Distribution: world
  9. Message-ID: <17h7riINNdki@agate.berkeley.edu>
  10. NNTP-Posting-Host: paris.cs.berkeley.edu
  11.  
  12. Easy question:
  13.  
  14. What's the easiest way of getting the address of the
  15. current stack frame from a C procedure?
  16.  
  17. One rather unreliable way is the following:
  18.  
  19.     f()
  20.     {
  21.         int x[1];
  22.         int *frame = x - 12;
  23.         ...
  24.     }
  25.  
  26. The 12 could be a different number and needs to be
  27. hand-tuned every time the body of f changes.  Bleah.
  28.  
  29. It would be nice to do it with a call to an assembly
  30. language routine.  But it's not trivial, because there
  31. could be a call to the stack overflow handler between
  32. f and the assembly language routine.
  33.  
  34. Can it be done using inline assembly with `asm'? 
  35. And if yes, how?
  36.  
  37. My eternal gratitude in advance.  --Luigi
  38.