🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Luigi Semenzato Thu, 27 Aug 1992 00:32
getting value of B02 from C
#123
Author: 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
Re: getting value of B02 from C
#126
Author: Luigi Semenzato
Date: Thu, 27 Aug 1992 17:53
17 lines
866 bytes
Thanks to jjd@teak.cray.com, and others, for the following simple
solution:

         IDENT     GETB02
         ENTRY     GETB02

         SECTION   CODE

GETB02   ENTER     NP=0,MODE=BASELVL
         A5        B02
         S1        A5
         EXIT      MODE=BASELVL

         END

This routine can never cause a stack overflow (it never uses
the stack at all), so my fears where unfounded.  --Luigi
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads