6.26.5 Examining data and code

The following words inspect the stack non-destructively:

... ( x1 .. xn – x1 .. xn  ) gforth-1.0 “...”

smart version of .s

.s ( ) tools “dot-s”

Display the number of items on the data stack, followed by a list of the items (but not more than specified by maxdepth-.s; TOS is the right-most item.

f.s ( ) gforth-0.2 “f-dot-s”

Display the number of items on the floating-point stack, followed by a list of the items (but not more than specified by maxdepth-.s; TOS is the right-most item.

f.s-precision ( – u  ) gforth-1.0 “f.s-precision”

A value. U is the field width for f.s output. Other precision details are derived from that value.

maxdepth-.s ( – addr  ) gforth-0.2 “maxdepth-dot-s”

A variable containing 9 by default. .s and f.s display at most that many stack items.

There is a word .r but it does not display the return stack! It is used for formatted numeric output (see Simple numeric output).

The following words work on the stack as a whole, either by determining the depth or by clearing them:

depth ( – +n  ) core “depth”

+n is the number of values that were on the data stack before +n itself was placed on the stack.

fdepth ( – +n  ) floating “f-depth”

+n is the current number of (floating-point) values on the floating-point stack.

clearstack ( ... –  ) gforth-0.2 “clear-stack”

remove and discard all/any items from the data stack.

fclearstack ( r0 .. rn –  ) gforth-1.0 “f-clearstack”

clear the floating point stack

clearstacks ( ... –  ) gforth-0.7 “clear-stacks”

empty data and FP stack

The following words inspect memory.

? ( a-addr –  ) tools “question”

Display the contents of address a-addr in the current number base.

dump ( addr u –  ) tools “dump”

Display u lines of memory starting at address addr. Each line displays the contents of 16 bytes. When Gforth is running under an operating system you may get Invalid memory address errors if you attempt to access arbitrary locations.