Browse Prior Art Database

C Stack Switching Function Call

IP.com Disclosure Number: IPCOM000119271D
Original Publication Date: 1991-Jan-01
Included in the Prior Art Database: 2005-Apr-01
Document File: 2 page(s) / 69K

Publishing Venue

IBM

Related People

Jordan II, LE: AUTHOR

Abstract

Disclosed is a method that allows a C language routine to switch to a new stack upon entry and to change back to the old stack before exiting the routine. This method may be used by routines that require a larger stack than is provided by the caller.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 52% of the total text.

C Stack Switching Function Call

      Disclosed is a method that allows a C language routine to
switch to a new stack upon entry and to change back to the old stack
before exiting the routine.  This method may be used by routines that
require a larger stack than is provided by the caller.

      This method is based on the IBM C language compiled to run on
IBM OS/2*. However, it may be modified to be used with any C language
routine compiled to run on stack base computers.

      Two assembly language routines perform the actual stack
switching.  The interfaces are as follows:
       /* switch_stack Routine */
                           /* Routine called to switch to a new
stack.
The routine returns to the caller with using the new stack.  The
caller must call switch_back before the calling routine exits */ void
switch_stack (newstack,length) char * newstack; /* Address of the new
stack */ unsigned length; /* length of new stack      */ /*
switch_back Routine */ /* Routine called to switch back to the old
stack. */ void switch_back  (newstack,length) char * newstack; /*
Address of the new stack */ unsigned length; /* length of new stack
*/

      The figure illustrates the way in which the stack is switched.

      The IBM OS/2 C language compiles code that utilizes the stack
in the following way:
      1.   The function's automatic variables are contained
           in the stack which is addressed by the SS register
           and the BP register.
      2.   Upon entry to a function, the contents of the BP
           register is pushed on the...