Field Service Manual December 2003
Page 26 of 276
In LTL, the contents of the stack cannot be seen, you can only visualize the TOS-
number. To do this, two words are available: the ?-word and the .-word. The ?-word
prints the number in TOS on the screen and leaves the stack intact; the .-word prints
the number and drops it too. This means that the .-word is a shorthand notation for a ?
DROP command.
Example
? swap . <>
This line will print the numbers 1 and 2 on the screen, and leave only the 1 on the
stack.
TOS: 1
Most of the LTL-words eat a number from the stack(Other LTL-words
put a number on the stack); to keep the number on TOS for later use, the DUP
(duplicate) word is available. To completely clear the stack the CLRSTCK (clear
stack) word is used. You can store the TOS-number in a previously declared variable
with the name := command.
Example
DUP a := <>
Duplicates the 1 on the stack and takes one off to store in the variable A.
TOS: 1 TOS: 1
1 ---->
A: 0 A: 1
Now that we know how to handle integers, variables and stack operations, the
moment has come to start doing something with these numbers. A first set of words
handles the standard mathematical operations: they are the +, -, *, /, % (modulo)
functions. These operators take two numbers from the stack, perform the function and
push the result on the stack. Keep in mind that LTL computes with integer numbers
only.
Examples (start from an empty stack)
64 55 - . <>
This sequence pushes 64 and 55 on the stack, the - word pops 55 and subtracts it from
64 (the 64 is popped too) and pushes the result (9) back on the stack. The .-word
prints the result on the screen and empties the stack.
Now try to find out these:
1e2 34 + . <> ----> 134
12 20 * . <> ----> 240
56 5 / . <> ----> 11
56 5 % . <> ----> 1
2 3 4 + * . <> ----> 14
208 13 8 * ? / . <> ----> 1042