Stack Operations
public domain software by Daniel J. Bishop

Notepad users:  Don't forget to turn on word wrap.

Many programmers complain about the limitations of TI-83 basic.  Their complaints are justified: 83 basic has one-letter variable names, no 3D arrays, no string arrays (although you can simulate these: see my TI-83 Phone Book for a demonstration of this), and NO RECURSION.  That last limitaion is no more: the programs in this archives will allow you to simulate recursive functions.
*****************************************************************************
Naming conventions for 83-basic functions:
(Other programmers may use different conventions.  These are one recommended standard.)

Subprogram used by one program:
     name = theta + 2-letter abbr. for main program
            + 5-letter abbr. for sub description
     example: \theta\SLDATE is the calendar subroutine for SOLID

Function used by multiple programs:
     name = 2 thetas + function name
     example: see below

Function call:
     {parameter list} -> \L\PARAM
     prgm\theta\\theta\ABCDEF     // replace ABCDEF with function name

Function:
     (non-I/O statements)
     {return value} -> \L\RET
     DelVar \L\LOCAL     // delete local variables

This will make much more sense when I release a function library.
*****************************************************************************
Programs in this archive:
__PPUSH.83P     sub to push PARAM onto stack
__PPOP.83P      sub to pop PARAM from stack
__LPUSH.83P     sub to push LOCAL onto stack
__LPOP.83P      sub to pop LOCAL from stack
*****************************************************************************
Example:  These programs find n! using the recursive definition n!=n(n-1)!  This is just a demonstration of how PUSH and POP are used: In a real program, you would prefer to use ! from the MATH\PRB menu.

PROGRAM:FCTORIAL
:{0} -> \L\STACK           // clear stack
:Prompt N

:{N} -> \L\PARAM           // RET = factorial(N)
:prgm\theta\\theta\FACTRL

:Disp "","N!=",\L\RET(1)

PROGRAM:\theta\\theta\FACTRL
// "function" to find n!
// precondition: \L\PARAM = {n}
// postcondition: \L\RET = {n!}
:If \L\PARAM(1)=0          // test for base case
:Then
:{1} -> \L\RET             // base case, 0! = 1
:Else
:prgm\theta\\theta\PPUSH   // push param onto stack

:\L\PARAM-1 -> \L\PARAM    // find (n-1)!
:prgm\theta\\theta\FACTRL

:prgm\theta\\theta\PPOP    // restore old param
:\L\PARAM*\L\RET -> \RET\  // n! = n(n-1)!
:End

Symbols used:
->          STO key
\L\         LIST\OPS\B
\theta\     self-explanatory
//          comment: don't type this in your programs
*****************************************************************************
Contact me:
If you have any questions, please e-mail me at danb2k@hotmail.com