FCV - layout of Function Control Vector.

This description applies to the FCV which describes the main B stack, as well as the FCVs which describe stacks for co-routines.

Offsets are with respect to the co-routine pointer (cp=x6).

Format:

Offset   Upper     All   Lower   Comments
  -8  tsx1 entry                 Used to make initial entry
  -7  4                  nargs   Nargs word for entry routine
  -6  tra               falloff  Transfer to falloff routine
  -5  caller              size   FCV of caller; size of FCV
  -4  passer              type   FCV of passer; type of pass
  -3  top                 base   Absolute stack addresses
  -2  high               space   High water mark; user info size
  -1               sp            Safe store for stack pointer
   0  start of user info         co-routine pointer
   1
   2
   .               user info vector
   .
   .
<size>                           top of user info vector

Description:

The FCV contains the description of the co-routine. It stores the address the co-routine was at when it was suspended, as well as pointers to the caller (parent) and passer (brother) co-routines.

The first time the co-routine is entered, it is by a transfer to FCV[-8]. The bottom three words of the FCV make up a "function template" which calls the user-supplied entry function to the co-routine. If the entry function ever returns, it will be to this function template, and the "tra~falloff" instruction will be executed. This will transfer control to the falloff routine. Normally this is equivalent to doing a DETACH, but may be set by the use of ENDING. The use of a function template sets x1 so that NARGS works correctly.

The stack allocated for the co-routine described by this FCV is normally contiguous with the top (high address) of the user info vector. The notable exception is the main B stack, which is not contiguous with the FCV but is allocated dynamically from available memory. The stack start is rounded up to an odd boundary.

When the stack overflow checking code is being used, the stack high water mark is monitored with respect to the absolute stack addresses. If the high water mark ever runs off the top of the stack, an error message is printed and your program ends.

Copyright © 1996, Thinkage Ltd.