Mon Aug 16 07:45:09 CEST 2010

Explicit recursion stack

To eliminate recursive calls in C and replace them with an explicit
stack, use the following approach:

  1. Make the code self-recursive by unrolling mutually recursive
     calls.  This is necessary to provide a single "context" to the
     loop.  The stack will be in that context.

  2. Replace the recursive call with a CALL macro that pushes the
     current data structure pointer to the stack and jumps to the
     entry point.

  3. Replace the entry point to examine the top of the stack.