LT4335 stack description.
Version of 6 July 2011.

The registers are organized into a stack, the standard last-in-first-out data structure of computer science. A term for placing items into the stack is pushing; for removing them, pulling. The item most recently pushed is designated #0; the next-newest is #1, et cetera. The corresponding meta-registers are named ##0, ##1, and so forth. Further, #0old means the value of #0 before an instruction is executed, and #0new after. Meta-registers are subscripted the same way.

Complicated calculations are not hampered by the fact the the CPU contains only 64 registers, because the stack overflow area, implemented as ram, will normally be large enough to hold thousands of data items.

In a multitasking environment effected by timesharing, each task should have a separate region within the overflow area. At a context switch:

  1. The registers of the exiting task are flushed to its overflow region.
  2. The CPU's stack information registers are changed to indicate the entering task's overflow region.
  3. The CPU's registers are primed from the entering task's overflow region.
  4. Processing resumes.
There is no need to copy a task's entire overflow region, which could contain millions of bits.

A reasonable implementation of that portion of that stack lying within the CPU (in other words, the registers) is a circular buffer. When overflow is anticipated, the CPU will write data from the bottom stack locations (such as #62 and #63) to the overflow area. In the opposite case, if the CPU portion of the stack starts to underflow, data is retrieved from the stack overflow area.

For the task currently running, the CPU maintains three stack information registers pertaining to the layout of the stack overflow area:

The machine will throw an exception if a pull is requested when the CPU registers and the tasks's overflow region are both empty (profound underflow), or if a push is requested when the CPU registers and the tasks's overflow region are both full (profound overflow).

To foster efficiency, information transfer between the CPU and stack overflow area will take place at unpredictable times, and within the overflow area the machine will use an undocumented data structure. Although it is difficult for a program to access the overflow area, writing to it will likely cause corruption, and reading it will probably yield garbage. All that a program may assume is that the CPU will maintain integrity between the registers and overflow area.

In a multiprocessor system, each CPU must have its own private stack overflow area.