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


A stack comment is a one line diagram of the effect of a word's execution on
the parameter stack. Stack comments may also show compile mode or the return
stack. The purpose of a stack comment is to unambiguously show the effect of a
word. See the stack section. A stack comment: ( before.parameter --
after.parameter ).

General comments tell what a word does, or why it has been defined. A short
explanation comment should accompany each word defined. Long definitions may
contain many comments. By commenting well, your program will be easier for
others to understand and easier for you to maintain. See the example files for
the use of both types of comments.


Memory

Pocket Forth uses memory in six ways. There are two stacks, variables, the
dictionary, free memory available to the dictionary and absolute addresses.

Stack addressing is implied, that is, you push and pop, and the stack
determines what address the actions access. Variable, dictionary, and free
memory addressing are all done with a 16 bit relative address. Absolute
addresses cover the entire addressing range of the 680x0 with a 32 bit double
number.

Understanding the use of relative and absolute addressing is vital to
programming Pocket Forth.

Absolute Addressing

An absolute address is the actual address as seen by the microprocessor.
Pocket Forth treats absolute addresses as double numbers. A double number is
two consecutive 16 bit numbers or a 32 bit number. The double number words
(such as "2swap", "d+" and "2@") can manipulate absolute addresses. Absolute
addressing allows access to any address whether 24 bit or 32 bit addressing
mode is used.

In addition to double number words, Pocket Forth has some words to deal
directly with absolute addresses. The words "l@", "dl@", "l!" and "dl!" read
and write absolute addresses outside of the relative address range.

See the glossary for the specifics of using double number and absolute
addressing words.

Relative Addressing

The addresses used within Pocket Forth are relative addresses, that is, 16 bit
numbers, relative to a base address. Pocket Forth can be anywhere in memory
and relative addresses will remain constant.