"Pocket Forth manual.V0.6.5" - читать интересную книгу автора (Heilman C.)

Relative addressing uses the 'indirect with displacement' addressing mode of
the 680x0. Addresses within ▒32K bytes of the base address can be accessed
using a 16 bit relative address. Pocket Forth's dictionary starts at zero and
uses only positive relative addresses, so the maximum dictionary size is 32K
bytes.

Free memory, that is, memory available for dictionary expansion, is determined
with the word "room". Pocket Forth is distributed with the maximum amount of
free space available. The default amount can be changed by adjusting the
'freeSize' variable. Setting a size greater than 32 kbytes will cause a crash.

'Address' or the abbreviation 'addr' usually means a relative address.
Relative and absolute addresses can be converted from one to the other. The
word ">abs" converts a relative address to a double number absolute address.

The word ">rel" converts an absolute address to a relative address. Only
absolute addresses within the relative addressing space will be correctly
converted. Absolute addresses outside of this range are mapped into the
relative addressing space, causing the wrong address to be calculated.

Stacks

The stack data structure is used throughout the computer world, but most
languages hide their stacks. On the other hand, Forth stacks allow complete
access.

Like most Forths, Pocket Forth uses a parameter stack and a return stack. The
term 'the stack' used by itself usually means the parameter stack. In
contrast, 'the stack' in other languages means the system stack, which is
Pocket Forth's return stack.

The parameter stack, used to pass values to and from routines, is under your
full control. It holds up to 1024 sixteen bit numbers or about 200 floating
point numbers. See the error section about under- and overflow conditions.

[figure 2]

Because the return stack is the system stack, it is used for subroutine
threading by Pocket Forth and other programs, including the operating system.
Runtime threading by pushing and popping addresses to the return stack is
handled automatically by the processor.

The return stack can also be used explicitly to store temporary data and to
interface with toolbox routines. Used for data storage the return stack makes
definitions smaller and faster. Here are two versions of a word that returns a
product and a quotient:

: PANDQ ( n1 n2 n3 -- n1*n3 n2/n3 ) dup rot swap / rot rot * swap ;
: PANDQ ( n1 n2 n3 -- n1*n3 n2/n3 ) >r swap r * swap r> / ;