OpenBoot 3.x Command Reference Manual

Displaying Stack Contents

The contents of the stack are normally invisible. However, properly visualizing the current stack contents is important for achieving the desired result. To show the stack contents with every ok prompt, type:


ok showstack
44 7 ok 8
44 7 8ok noshowstack
ok 

The topmost stack item is always shown as the last item in the list, immediately before the ok prompt. In the above example, the topmost stack item is 8.

If showstack has been previously executed, noshowstack will remove the stack display prior to each prompt.


Note -

In some of the examples in this chapter, showstack is enabled. In those examples, each ok prompt is immediately preceded by a display of the current contents of the stack. The examples work the same if showstack is not enabled, except that the stack contents are not displayed.


Nearly all words that require numeric parameters fetch those parameters from the top of the stack. Any values returned are generally left on top of the stack, where they can be viewed or consumed by another command. For example, the Forth word + removes two numbers from the stack, adds them together, and leaves the result on the stack. In the example below, all arithmetic is in hexadecimal.


44 7 8 ok +
44 f ok +
53 ok 

Once the two values are added together, the result is put onto the top of the stack. The Forth word . removes the top stack item and displays that value on the screen. For example:


53 ok 12
53 12 ok .
12
53 ok .
53
ok   (The stack is now empty)
ok 3 5 + .
8
ok   (The stack is now empty) 
ok . 
Stack Underflow 
ok