Interactive Computer Systems, Inc. fig-FORTH Manual
PDF
Document
Publicité
Publicité
..--
~llllllltMiflllllltiiiiiiiiiiiii'*'IIIIIIIIINIIti
'
i
!
.
!-.
~
INTERACTIVE COMituTER SYSTEM , INC.
840) DtMARCO ROAD
• TAMPA, FLORIDA33814
Cc<. P.. T~::.
-•
..
..-----
I~
I
I
(813) 884-11270
!•
--
_ _H _ _IIIIIIIIIIItiiNIIIIIIIIIII&a......lllllllllltlltiiM_ _ _ _IIIIIIIIIIIIIIII;
~
C...,py .
-~~
I
fig-FORTH
i
INSTALLATION MANUAL
i
GLOSSARY
i
MODEL
•~
;
-----!
!
.~
~
~
!~-
-j
I
•
~
RELEASE 1
I
•
WITH COMPILER SECURITY
I
•
I
I
AND
!
•
I
---------..-~
i
!
!
VARIABLE LENGTti NAMES
-
§
~
-
§
..-i--
~{'}
t_ • .:_
-
i
~
i
I
I
------------!•
ii
MAY 1979
!
~
Provided through the courtesy of the Forth Interest Group, P.0. Box 1105,
San Carles 1 CA 94070.
•
i
~
Further distribution of this public domain publication rrust include this notice.
a
I
I
~
L l l t l l t l l t l l l l l l l l l l l l l l t i i i i M I - . . e - - · · - 1 - - - ·........,...,.,. .llltllllttltlllllltlftltflllltllltllflltlll_ _ _ _
FORTH INTEREST GROUP • ••• • P. 0. Box 1105 · · · • · San Carlos , Ca. 94070
e
.
•
••e
!flltllllllllllllltltlllllllllllllliiiUIIIIIIIIIIIIIIIIfllllllllllllllllllllllllllllllllllllltiiiiiiiiiiiiiiMIItllltllll. .ltllllllllllllllll-111. .1111
.
~
5
-~
5
•
;e
I•
es
!
I
I
s·
Ie
-
I
----
I
fig-FORTH
•
INSTALLATION MANUAL
!!
GLOSSARY
i•
MODEL
I
---I
•
ii
I
I~
-
ii
!
!
!
ii
I
•
•ii
I
•§
I
~
I-
Ie
I-
WITH COMPILER SECURITY
-----•
.
VARIABLE LENGTM NAMES
•!I•
ii
RELEASE 1
!s
!
I
-I•
~
AND
ii
•
!I
-•
.
--
!!
!!
e
e
e
I
!a
!!
e
~~
I~
•
I
;~
!!
I
•
!
~-
§
e~
•
~
~
1
•
I
i
I
272
!
•
MAY 1979
•
e
I
Provided through the courtesy of the Forth Interest Group, P.0. Box 1105,
San Carlos, CA 94070.
~
I
i
J
I
Further diotrlbution of this public domain public:c:tion rrust include this notice.
L...,..."....,.llllliiiiiiiiNIIItlllllllllllllllllltllllllllllll........_.......lll"''"'lll........,.,..llltl"'"llllllll""....,..,.
FORTH INTEREST GROUP • • • • • P. 0. Box 110 5 • • • • • San Carlos, Ca. 94070
.
fig-FORTH INSTALLATION MANUAL
1.0
1.0
INTRODUCTION
2.0
DISTRIBUTION
3.0
MODEL ORGANIZATION
4.0
INSTALLATION
5.0
MEMORY MAP
6.0
DOCUMENTATION SUMMARY
3.0
INTRODUCTION
The fig-FORTH implementation project occurred
because a key group of Forth fanciers wished
to make this valuable tool available on a
In June of 1978,
personal computing level.
we gathered a team of nine systems level
programmers, each with a particular target
The charter of the group was to
computer.
translate a common model of Forth into assemIt
bly language listings for each computer.
was agreed that the group's work would be
This
distributed in the public domain by FIG.
publication series is the conclusion of the
work.
2.0
DISTRIBUTION
All publications of the Forth Interest Group
They may be further
are public domain.
reproduced and distributed by inclusion
of this credit notice:
This publication has bee~ made available
by the Forth Interest Group,
San Carlos, Ca 94070
P. 0. Box 1105,
MODEL ORGINIZATION
The fig-FORTH model deviates a bit from the
Existing
usual loading method of Forth.
systems load about 2k bytes in object form
and then self-compile the resident system
This technique allows
(6 to 8 k bytes).
customization within the h~gh level portion,
but is impractical for new implementors.
Our model has 4 to 5 k bytes written as assemThe remainder may be compiled
bler listings.
typing in the Forth high-level source, by
more assembly source, or by disc compilation.
This method enhances transportability ,
although the larger portion in assembly code
About 8k bytes of memory
entails more effort.
is used plus 2 to Sk for workspace.
3.1
MODEL OVER-VIEW
They
The model consists of 7 distinct areas.
occur sequentially from low memory to hi~h.
We intend that our primary recipients of the
Implementation Project be computer users
groups, libraries, and commercial vendors.
We expect that each will further customize for
No
particular c~mputers and redistribute.
restrictions are placed on cost, but we
Boot-up parameters
Machine code definitions
High level utility definitions
Installation dependent code
High level definitions
System tools (optional)
RAM memory workspace
FIG does
expect faithfulness to the model.
not intend to distribute machine readable
versions, as that entails customization,
revision, and customer support better reserved
for commerical vendors.
Of course, another broad group of recipients
of the work is the community of personal
We hope that our publications
computer users.
will aid in the use of Forth and increase
the user expectation of the performance of
high level computer languages.
FORTH INTEREST GROUP
o o o o o
P. 0. Box 110 5
o o • • •
San Carlos, Ca. 94070
3.2
MODEL DETAILS
Boot-up Parameters
This area consists of 34 bytes containing a
jump to the cold start, jump to the warm
re~start and initial values for user variables
These values are altered as
and registers.
you make permanent extensions to your
installati on.
When each of these words is executed, the
intepreter vectors from the definition
On
header to these code sequences.
specific implement ations it may be necessary
to preseve certain registers and observe
Understand the
operating system protocols.
implemento rs methods in the listing before
proceeding !
Machine Code Definition s
This area consists of about 600 to 800 bytes
of machine executable code in the form of
Its purpose is to
Forth word defintions .
convert your computer into a standard Forth
Above this code, the balance
stack computer.
of Forth contains a pseudo-cod e compiled of
"execution -addresses " which are sequences
of the machine iddress of the "code-fiel ds"
Ail execution
of other Forth definition s.
ultimately refers to the machine code
definition s.
High-level Utility Definition s
These are colon-def initions, user variables,
constants, and variables that allow you to
They
control the "Forth stack computer".
comprise the bulk of the system, enabling
you to execute and compile from the terminal.
If disc storage (or a RAM simulation of disc)
is available, you may also execute and compil~
Changes in the high-level
from this facility.
They may be made thru
area are infrequent .
the assembler source listings.
Installati on Dependertt Code
This area is the only portion that need
change between differertt installatio ns of the
Ther~ are four code
same computer cpu.
fragments:
Push the next ascii value (7 bits)
(KEY)
from the terminal keystroke to the
computatio n sta~k and execute NEXT.
Do not echo this
High 9 bits are zero.
character, especially a control character.
Pop the computatio n stack
(EMIT)
Display the low 7 bits
(16 bit value).
on the terminal device, then execute
Control characters have their
NEXT.
natural .functions .
For terminals with a break
{?TERMINAL )
key, wait till released and push to
the computatio n stack 0001 if it was
found depressed; otherwise 0000.
If no break key is availExecute NEXT.
able, sense any key depression as a
break (sense but don't wait for a key).
If both the above are unavailabl e,
simply push 0000 and execute NEXT.
(CR)
re~urn
Execute a terminal carriage
Execute NEXT.
and line feed.
This colon-def inition is the
R/W
It
standard linkage to your disc.
requests the read or write of a disc
It usually requires supporting
sector.
It may consist of
code definition s.
self-conta ined code or call ROM ~onitor
When R/W is assembled, its code
code.
field address is inserted once in
BLOCK and once in BUFFER.
An alternate version of R/W is
included that simulates disc storage
If you have over 16 k bytes
in RAM.
this is practical for startup and
limited operation with cassette.
High-level Definition s
The next section contains about 30 definitions involving user interactio n: compiling
aids, finding, forgetting , listing, and
These definition s are
number formating.
placed above the installatio n dependent code
That is, once
to facilitate modificati on.
your full system is up, you may rORGET part
of the high-level and re-compile altered
definition s from disc.
Sytsem Tools
A text editor and machine code assembler are
We are including a sample
normally resident.
editor, and hope to provide Forth assemblers .
The editor is compiled from the terminal
the first time, and then used to place the
editor and assembler source code on disc.
It is essential that you regard the assembly
listing as just a way to get Forth installed
Additions and changes must
on your system.
be planned and tested at the usual Forth high
level and then the assmbly routines updated.
Forth work planned and executed only at an
assembly level tends to be non-portab le, and
confusing.
RAM Workspace
For a single user system, at least 2k bytes
must be available above the compiled system
A 16k byte total system
(the dictionary ).
is most typical.
The RAM workspace contains the computatio n
and return stacks, user area, terminal input
buffer, di~c buffer and compilatio n space
for the dictionary .
FORTH INTEREST GROUP · · · · · P. 0. Box 1105 ·· · · · San Carlos, Ca. 94070
4.0
INSTALLATION
We see the following methods of getting a
functioning fig-FORTH system:
l.
2.
3•
4.
Buy loadable object code from
a vendor who has customized.
Obtain an assembly listing with
the installation dependent code
supplied by the vendor.
Assemble and execute.
Edit the FIG assembly listing
on your system, re-write the
I-0 routines, and assemble.
Load someone else's object code
up to the installation dependent
Hand assemble equivalents
code.
for your system and poke in with
Begin execution
your monitor.
and type in (self-compile) the
This takes
rest of the system.
about two hours once you understand the structure of Forth (but
that will take much more time!).
Let us examine Step 3, above, in fuller
If you wish to bring up Forth only
detail.
from this model, here are the sequential
steps:
4.1 Familiarize yourself with the model
written in Forth, t.he glossary, and specific
assembly listings.
Edit the assembly listings into your
4.2
Set the boot-up parameters at origin
system.
offset OA, OB (bytes) to 0000 (warning=OO).
Alter the terminal support code
4.3
(KEY, EHIT, etc,) to match your system.
Observe register protocol specific to your
implementation!
Place a break to your monitor at the end
4.4
of NEXT, just before indirectly jumping via
W is the Forth name
register W to execution.
for the register holding a code field address,
and may be differently referenced in your
listings.
Upon
Enter the cold start at the origin.
4.5
the break, check that the interpretive. pointer
IP points within ABORT and W points to SP!.
If COLD is a colon-definition, then the IP
has been initialized on the way to NEXT and
The
your testing will begin in COLD.
purpose of COLD is to initialize IP, SP, RP,
UP, and some user variables from the start-up
parameters at the origin.
4.7 Execution errors may be localized by
observing the above pointers when a crash
occurs.
4.8 After the word QUIT is executed
(incrementally), and you can input a "return"
key and get OK printed, remove the break.
You may have some remaining errors, but a
reset and examination of the above registers
will again localize problems.
4.9 When the system is interpreting from the
keyboard, execute EMPTY-BUFFERS to clear
You may test the disc
the disc buffer area.
64 TYPE
BLOCK
0
access by typing:
This should bring sector zero from the disc
to a buffer and type the first 64 characters.
This sector usually contains ascii text of the
If BLOCK (and R/W) doesn't
disc directory.
function--happy hunting!
5.0 If your disc driver differs from the
assembly version, you must create your own
This word does a range check (with
R/W.
error message), modulo math to derive sector,
track, and drive and passes values to a
sector-read and sector-write routine.
RAM DISC SIMULATION
If disc is not available, a simulation of
The
BLOCK and BUFFER may be made in RAM.
following definitions setup high memory as
Referenced 'screens' are then
mass storage.
This is
brought to the 'disc buffer' area.
a good method to test the start-up program
even if disc may be available.
HEX
( START OF BUFFER AREA
LO
4000 CONSTANT
( 10 SCREEN EQUIVALENT
6800 CONSTANT HI
( save boolean )
>R
R/W
* LO + DUP
B/BUF
?ERROR ( range check
> 6
HI
ENDIF
SWAP
IF ( read )
R>
CMOVE
B/BUF
Insert the code field address of R/W into
BLOCK and BUFFER and proceed as if testing
R/W simulates screens 0 thru 9 when
disc.
B/BUF is 128, in the memory area $4000 thru
$6BFF.
Continue execution one word at a time.
4.6
Clever individuals could write a simple trace
routine to print IP, W, SF, RP and the top of
Run in this single step mode
the stacks.
Note
until the greeting message is printed.
that the interpretation is several hundred
cycles to this stage!
FORTH INTEREST GROUP · · · · · R 0. Box 1105 · · · · · San Carlos, Ca. 94070
fig-FOR TH VARIABLE NAME FIELD
A major FIG innova tion in this model, is
the introd uction of variab le length definition names in compil ed diction ary entrie s.
Previo us method s only saved three letters and
the charac ter count.
The user may select the letter count saved,
See the
up to the full natura l length .
glossa ry defini tion for WIDTH.
In this model, the follow ing conven tions
have been establ ished.
1. The first byte of the name field has the
natura l charac ter count in the low 5 bits.
2. The sixth bit = 1 when smudge d, and will
preven t a match by (FIND) .
J, The sevent h bit = 1 for IMMEDIATE ~efin­
itions ; it is called the preced ence bit.
4. The eighth or sign bit is always = 1.
names'
s. The follow ing bytes containin the
WIDTH.
letter s, up to the value
6. In the byte contain ing the last letter
saved, the sign bit = 1.
7. In word addres sing comput er, a name may
be padded with a blank to a word bounda ry.
The return stack grows downwa rd from the user
Forty- eight
area toward the termin al buffer .
is in RO
origin
The
ient.
suffic
are
bytes
(R-zero ) and is loaded from a boot-up litera l.
The compu tation stack grows downwa rd from the
termin al buffer toward the diction ary, which
The origin of the stack is
grows upward .
is in variab le SO (S-zero ) and is loaded from
a boot-up litera l.
After a cold start, the user variab les contain
the addres ses of the above memory assignm ents.
An advanc ed user may reloca te while the
A newcom er should alter
system is runnin g.
The
the startup litera ls and execut e COLD.
word +ORIGIN is provide d for this purpos e.
+ORIGIN gives the addres s byte or word relative to the origin depend ing on the comput er
To change the backsp ace
addres sing method .
to contol H type:
HEX
08
OE
+ORIGIN
( byte addres ses)
The above method s are implem ented in CREATE .
BL WORD to bring
Rememb er that -FIND uses
the next text to HERE with the count precee dAll that is necess ary, is to limit by
ing.
WIDTH and toggle the proper delimi ting bits.
5.0
MEMORY MAP
The follow ing memory map is broadly used.
Specif ic install ations may require alterat ions
forfei t functio ns in future FIG
but you may
offerin gs.
The disc buffer area is at the upper bound of
It is compri sed of an integr al
RAM memory .
s, each B/BUF+ 4 bytes.
buffer
of
number
B/BUF is the number of bytes read from the
B/BUF must be a
disc, usually one sector .
power of two (64, 128, 256, 512 or 1024).
The consta nt FIRST has the value of the
addres s of the start of the first buffer .
LIMIT has the value of the first addres s
The distanc e betwee n
beyond the top buffer .
FIRST and LIMIT must be N*(B/BU F+4) bytes.
This N must be two or more.
Consta nt B/SCR has the value of the number of
1024 I B/BUF.
per screen ; i.e.
6.0
DOCUMENTATION SUMMARY
The follow ing manual s are in print:
Caltech FORTH Manual , an advanc ed manual with
Has some implem intern al details of Forth.
entatio n peculi arities . Approx . $6.50 from
the Caltech Book Store, Pasade na, CA.
Kitt Peak Forth Primer , $20.00 postpa id from
the Forth Intere st Group, P. o. Box 1105,
San Carlos , CA 94070.
Forth, Inc.
microFO RTH Primer , $15.00
815 Manhat tan Ave. Manhat tan Beach, CA 90266
Forth Dimens ions, newsle tter of the Forth
Intere st Group, $5.00 for 6 issues includ ing
F.I.G. P.o. Box 1105, San Carlos ,
membe rship.
94070
CA.
buffer~
48
The user area must be at least 34 bytes;
In a multi- user system ,
is more approp riate.
each user has his own user area, for his copy
This method allows reof system variab les.
entran t use of the Forth vocabu lary.
The termin al input buffer is decima l 80 bytes
If a
(the hex 50 in QUERY) plus 2 at the end.
differe nt value is desire d, change the limit
A parame ter in the boot-up
in QUERY.
litera ls locates the addres s of this area for
The backsp ace charac ter is also in the
TIB.
It is univer sally
boot-up origin parame tersw
expect ed that •irubou t" is the backsp ace.
FORTH INTEREST GROUP • • • • • P. 0. Box 1105 .• • • • • San Carlos, Ca. 94070
/ j
c:;-- PAD
~
25
0
~
1.0
Q)
(")
0(/)
~
Q)
(")
I
I
BOOT -UP Ll TERALS
DIO~NARY
''WORD" BUFFER
J ..;---
1
0 T ORIGIN
SP
Sfl
~
---;;..
Z-PAGE
[
--?>--
$0100
::J
Q)
U>
$200
---;;..
~AP
l
-
l
BOOT -uP LITERALS
DICTIONARY
''WORD" BUFFER
-~EXT-~~FF;R
USER AREA
DISC BUFFERS
STACK
~~-~
$009F - $0010
UP
<---
--E--
I
'"E--
}
~
.I ~
I
-]
- RETURN
--STACK
- TERMINAL
BUFFER
---
r-
~ [~
-->
I
ml
ul
DP
~E~ORY
6502
--? . . - - - - - - - - - - ,
~
• •
IN
~TIB
}
UP
FIRST
UMIT
Rp
-----:;.
STA~K
BUFFER
-fER~INAl
TEXT BUFFER
/
,.,
/
1
~PREV
~USE
fig-FORTH
I
!
/
!
//
AREA
RETURN
STACK
~E·
~AP
---?-
I
I
/
r
DISC BUFFERS
~E~ORY
l81FF
DP
---?
~
s fl'
sp
----:;..
----:>
R/1
RP
~
----'>
~
UP
FIRST
LI~IT
fig-FORTH
STANDARD
•
•
•
•
•
U"l
.........
0
.......
X
0
a:J
0
:-o
0
.,c0
:::0
G>
-4
m
g
-4
z
::c
-4
23
:::0
SP IS X REGISTER
RP IS STACK POINTER
OF CPU
JIB
IN
fl -tORIGIN
PAD
PREY
USE
fig-FORTH GLOSSARY
This glossary contains all of the word defThe
initions in Release l of fig-FORTH.
definitions are presented in the order of
their ascii sort.
The first line of each entry shows a symbolic
description of the action of the proceedure on
The symbols indicate the
the parameter stack.
order in which input parameters have been
Three dashes "---"
placed on the stack.
indicate the execution point; any parameters
In this
left on the stack are listed.
notation, the top of the stack is to the
right.
The symbols include:
addr
b
c
d
f
ff
n
u
t f
memory address
8 bit byte (i.e. hi 8 bits zero)
7 bit ascii character (hi 9 bits zero)
32 bit signed double intege~
most significant portion with sign
on top of stack.
boolean flag. O=false, non-zero=true
boolean false flag=O
16 bit signed integer number
16 bit unsigned integer
boolean true flag=non-zero
FORTH INTEREST GROUP
The capital letters on the right show definition characteristics:
c
E
LO
Ll
p
u
May only be used within a colon definA digit .indicates number
ition.
of memory addresses used, if other
than one.
Intended for execution only.
Level Zero definition of FORTH-78
Level One definition of FORTH-78
Will execute
Has precedence bit set.
even when compiling.
A user variable.
Unless otherwise noted, all references to
On
numbers are for 16 bit signed integers.
8 bit data bus computers, the high byte of
a number is on top of the stack, with the sign
For 32 bit signed double
in the leftmost bit.
numbers, the most significant part (with the
sign) is on top.
All arithemetic is implicitly 16 bit signed
integer math, with error and under-flow
indication unspecified.
P. 0. Box 1105 ····· San Carlos, Ca. 94070
LO
(+LOOP)
Save the stack position in CSP.
Used
as part of the compiler security.
(ABORT)
LO
dl
d2
Generate from a double number dl, the
next ascii character which is placed
in an output string.
Result d2 is
the quotient after division by BASE,
and is maintained for further processing.
Used between <II and #>.
See 1/S.
(DO)
n
addr
Store 16 bits of n at address.
Pronounced "store".
n
C2
The run-time proceedure compiled
by +LOOP, which increments the loop
index by n and tests for loop completion.
See +LOOP.
!CSP
II
II>
d
addr
count
LO
Terminates numeric output conversion
by dropping d, leaving the text
address and character count suitable
for TYPE.
liS
d2
d1
LO
Generates ascii text in the text output buffer, by the use of II, until
a zero double number n2 results.
Used between <# and #>.
addr
P,LO
Used in the form:
nnnn
Leaves the parameter field address
of dictionary word nnnn.
As a compiler directive, executes in a colondefinition to compile the address
as a literal.
If the word is not
found after a search of CONTEXT and
CURRENT, an appropriate error message is given.
Pronounced "tick".
Executes after an error when WARNING
is -1.
This word normally executes
ABORT, but may be altered (with care)
to a user's alternative proceedure.
(FIND)
addrl
addr2
--- pfa b tf
(ok)
addrl
addr2
ff
(bad)
Searches the dictionary starting at
the name field address addr2, matching to the text at addrl.
Returns
parameter field address,
length
byte of name field and boolean true
for a good match.
If no match is
found, only a bool~an false is left.
(LINE)
nl
n2
addr
count
Convert the line number nl and the
screen n2 to the disc buffer address
containing the data.
A count of 64
indicates the full line text length.
(LOOP)
C2
The run-time proceedure compiled by
LOOP which increments the loop index
and tests for loop completion.
See LOOP.
(NUMBER)
dl
addrl
addr2
d2
Convert the ascii text beginning at
addrl+l with regard to BASE.
The new
value is accumulated into double
number dl, being left as d2.
Addr2
is the address of the first unconvertable digit.
Used by NUMBER.
P, LO
Used in the form:
( ecce)
Ignore a comment that will be
delimited by a right parenthesis
on the same line.
May occur during
execution or in a colon-definition.
A blank after the leading parenthesis
is required.
(
. ")
C+
The run-time proceedure, compiled by
."which transmits the following
in-line text to the selected output
device.
See • "
(;CODE)
The run-time proceedure, compiled by
;CODE, that rewrites the code field
of the most recently defined word to
point to the following machine code
sequence.
See ;CODE.
FORTH INTEREST GROUP
c
The run-time proceedure compiled by
DO which moves the loop control parameters to the return stack.
See DO.
nl
n2
prod
Leave the signed product of
signed numbers.
LO
two
*I
n1
n2
n3
n4
LO
Leave the ratio
n4 = nl*n2/n3
where all are signed numbers.
Retention of an intermediate 31 bit
product permits greater accuracy than
would be available with the sequence:
nl
n2
* n3 I
*/MOD
n1
n2
n3
n4
nS
LO
Leave the quotient nS and remainder
n4 of the operation
nl*n2/n3
A 31 bit intermediate product is
used as for */.
c
P. 0. Box 110 5
San Carlos, Ca. 94070
7
LO
+
sum
n2
nl
Leave the sum of nl+n2.
+!
LO
addr
n
Add n to the value at the address.
Pronounced "plus-store" .
+-
n3
n2
nl
Apply the sign of n2 to nl. which
is left as n3.
+BUF
f
addr2
addl
Advance the disc buffer address addrl
to the address of the next buffer
Boolean f is false when addr2
addr2.
is the buffer presently pointed to
by variable PREV.
+LOOP
(run)
nl
P,C2,LO
(compile)
n2
addr
Used in a colon-defini tion in the
form:
+LOOP
nl
DO
At run-time, +LOOP selectively
controls branching back to the corresponding DO based on nl, the loop
The signed
index and the loop limit.
increment nl is added to the index
and the total compared to the limit.
The branch back to DO occurs until
the new index is equal to or greater
than the limit (nl>O), or until the
new index is equal to or less than
Upon exiting the
the limit (nl<O).
loop, the parameters are discarded
and execution continues ahead.
-DUP
-FIND
(found)
tf
pfa b
(not found)
ff
Accepts the next text word (delimited
by blanks) in the input strean to
HERE, and searches the CONTEXT and
then CURRENT vocabularies for a
If found, the
matching entry.
dictionary entry's parameter field
address, its length byte, and a
Otherwise,
boolean true is left.
only a boolean false is left.
-TRAILING
n2
addr
nl
addr
Adjusts the character count nl of a
address to
text string beginning
suppress the output of trailing
i.e. the characters at
blanks.
addr+nl to addr+n2 are blanks.
LO
n
Print a number from a signed 16 bit
two's complement value, converted
according to the numeric BASE.
A trailing blanks follows.
Pronounced "dot".
addr
n
Leave the memory address relative
by n to the origin parameter area.
n is the minimum address unit, either
byte or word. This definition is used
to access or modify the boot-up
parameters at the origin area.
Used in the form:
." ecce"
Compiles an in-line string ecce
(delimited by the trailing ") with an
execution proceedure to transmit the
text to the selected output device.
"
If executed outside a definition,
will immediately print the text until
The maximum number of
the final "•
an installation
characters may be
See (.").
dependent value.
.• LINE
n2
nl
Print the number nl right aligned in
No
a field whose width is n2.
following blank is printed.
I
LO
quat
n2
nl
Leave the signed quotient of nl/n2.
/MOD
LO
quot
rem
n2
nl
Leave the remainder and signed
The remainder has
quotient of nl/n2.
the sign of the dividend.
LO
nl-n2.
P,LO
-->
Continue interpretatio n with the
next disc screen. (pronounced
next-screen) .
FORTH INTEREST GROUP
scr
line
Print on the terminal device, a line
of text from the disc by its line and
Trailing blanks are
screen number.
suppressed.
.R
LO
n
Store n into the next available dictionary memory cell, advancing the
(comma)
dictionary pointer.
diff
n2
nl
Leave the difference of
P,LO
II
At compile time, +LOOP compiles
the run-time word (+LOOP) and the
branch offset computed from HERE to
the address left on the stack by
n2 is used for compile time
DO.
error checking.
+ORIGIN
(if zero)
nl
nl
LO
(non-zero)
nl
nl
nl
Reproduce nl only if it is non-zero.
Th~s is usually used to copy a value
just before IF, to eliminate the need
for an ELSE part to drop it.
0.
0
0.
P. 0. Box 110 5
San Carlos, Ca. 94070
0 1 2 3
n
These small numbers are used so often
that is is attractive to define them
by name in the dictionary as constants.
0<
0=
OBRANCH
n
f
LO
Leave a true flag if the number is
less than zero (negative), otherwise
leave a false flag.
n
f
LO
Leave a true flag is the number is
equal to zero, otherwise leave a
false flag.
f
C2
The run-time proceedure to conditionally branch.
If f is false (zero),
the following in-line parameter is
added to the interpretive pointer to
branch ahead or back.
Compiled by
IF, UNTIL, and WHILE.
1+
nl
n2
Increment nl by 1.
2+
nl
n2
Leave nl incremented by 2.
;S
P,LO
Stop interpretatio n of a screen.
;S is also the run-time word compiled
at the end of a colon-defini tion
which returns execution to the
calling proceedure.
<
nl
n2
f
LO
Leave a true flag if nl is less than
n2; otherwise leave a false flag.
<#
<BUILDS
Ll
P,E,LO
Used in the form called a colondefinition:
: ecce
Creates a dictionary entry defining
ecce as equivalent to the following
sequence of Forth word definitions
until the next ' ; ' or ';CODE'.
The compiling process is done by
the text interpreter as long as
STATE is non-zero.
Other detaila
are that the CONTEXT vocabulary is
set to the CURRENT vocabulary and
that words with the precedence bit
set (P) are executed rather than
being compiled.
P,C,LO
Used in the form:
ecce
;CODE
assembly mnemonics
Stop compilation and terminate a new
defining word ecce by compiling
(;CODE).
Set the CONTEXT vocabulary
to ASSEMBER, assembling to machine
code the following mnemonics.
When ecce later executes in the form:
ecce
nnnn
the word nnnn will be created with
its execution proceedure given by
by the machine code·followin g ecce.
That is, when nnnn is executed, it
does so by jumping to the code after
nnnn.
An existing defining word
must exist in ecce prior to ;CODE.
FORTH INTEREST GROUP
•
o o •
•
C,LO
Used within a colon-defini tion:
ecce
<BUILDS
DOES>
Each time ecce is executed, <BUILDS
defines a new word with a high-level
execution proceedure.
Executing ecce
in the form:
ecce
nnnn
uses <BUILDS to create a dictionary
entry for nnnn with a call to the
DOES> part for nnnn.
When nnnn is
later executed, it has the address of
its parameter area on the stack and
executes the words after DOES> in
ecce.
<BUILDS and DOES> allow runtime proceedures to written in highlevel rather than in assembler code
(as required by ;CODE).
nl
n2
f
LO
Leave a true flag if nl=n2; otherwise leave a false flag.
>
nl
n2
f
LO
Leave a true flag if nl is greater
than n2; otherwise a false flag.
>R
n
C,LO
Remove a number from the computation
stack and place as the most accessable on the return stack.
Use should
·be balanced with R> in the same
definition.
P,C,LO
Terminate a colon-defini tion and
stop further compilation.
Compiles
the run-time ;S.
;CODE
LO
Setup for pictured numeric output
formatting using the words:
<II
II /Is SIGN II>
The conversion is done on a double
number producing text at PAD.
addr
LO
Print the value contained at the
address in free format according to
the current base.
.?COMP
Issue error message if not compiling.
?CSP
Issue error message if stack position
differs from value saved in CSP.
P. 0. Box 110 5 · · · · · San Carlos, Ca. 94070
9
?ERROR
f
n
Issue an error message number n,
the boolean flag is true.
B /BUF
if
n
This constant leaves the number of
bytes per disc buffer, the byte count
read from disc by BLOCK.
?EXEC
Issue an error message if not executing.
B/SCR
?LOADING
Issue an error message if not loading
?PAIRS
n
This constant leaves the number of
blocks per editing screen.
By convention, an editing screen is 1024
bytes organized as 16 lines of 64
characters each.
nl
nZ
Issue an error message if nl does not
equal n2.
The message indicates that
compiled conditionals do not match.
BACK
addr
Calculate the backward branch offset
from HERE to addr and compile into
the next available dictionary memory
address.
Issue an error message is the stack
is out of bounds.
This definition
may be installation dependent.
BASE
addr
U,LO
A user variable contaning the current
number base used for input and output conversion.
BEGIN
addr
n
(compiling)
P,LO
Occurs in a colon-definition in form:
BEGIN
UNTIL
BEGIN
AGAIN
BEGIN
WHILE
REPEAT
At run-time, BEGIN marks the start
of a sequence that may be repetitively executed.
It serves as a return
point from the correspoinding UNTIL,
AGAIN or REPEAT.
When executing
UNTIL, a return to BEGIN will occur
if the top of the stack is false;
for AGAIN and REPEAT a return to
BEGIN always occurs.
?STACK
?TERMINAL
f
Perform a
test of the terminal keyboard for actuation of the break key.
A true
flag
indicates
actuation.
This
definition
is
installation
dependent.
@
addr
n
LO
Leave the 16 bit contents of address.
ABORT
LO
Clear the stacks and enter the execution state.
Return control to the
operators terminal, printing a message appropriate to the installation.
ABS
At compile time BEGIN leaves its return address and n for compiler error
checking.
n
u
LO
Leave the absolute value of n as u.
BL
AGAIN
addr
n --- (compiling)
P,CZ,LO
Used in a colon-definion in the form:
BEGIN
AGAIN
At run-time, AGAIN forces execution
to return to corresponding BEGIN.
There is no effect on the stack.
Execution cannot leave this loop
(unless
R>
DROP
is executed one
level below).
BLANKS
addr
count
Fill an area of memory begining at
addr with blanks.
BLK
addr
U,LO
A user variable containing the block
number being interpreted.
If zero,
input is being taken from the terminal input buffer.
BLOCK
n
addr
LO
Leave the memory address of the block
buffer containing block n.
If the
block is not already in memory, it is
transferred from disc to which ever
buffer was least recently written.
If the block occupying that buffer
has been marked as updated, it is rewritten to disc before block n is
read into the buffer.
See also
BUFFER,
R/W
UPDATE
FLUSH
At compile time, AGAIN compiles
BRANCH with an offset from HERE to
~ddr.
n is used for compile-time
error checking.
ALLOT
LO
Add the signed number to the dictionary pointer DP.
May be used to
reserve dictionary space or re-origin
memory.
n is with regard to computer
address type (byte or word).
AND
nl
n2
nZ
LO
Leave the bitwise logical and of nl
and n2 as n3.
n
FORTH INTEREST GROUP
o • • • •
c
A constant that leaves the ascii
value for "blank".
P. 0. Box 1105 ·
o • • •
San Carlos, Ca. 94070
10
COMPILE
C2
When the word containing COMPILE
executes, the execution address of
the word following COMPILE is copied
(compiled) into the dictionary.
This allows specific compilation
situations to be handled in additon
to simply compling an execution
address (which the interpreter
already does).
CONSTANT
n
LO
A defining word used in the form:
n CONSTANT ecce
to create word ecce, with its parameter field containing n.
When ecce
is later executed,
it will push
the value of n to the stack.
CONTEXT
addr
O,LO
A user variable containing a pointer
t~ the vocabulary within which dictionary searches will first begin.
COUNT
addrl
addr2 n
LO
Leave the byte address addr2 and byte
count n of a mes~age text beginning
at address addrl.
It is presumed
tha~ the f.irst byte at addrl contains
the text byte count and the actual
text starts with the second byte.
Typically COUNT is followed by TYPE.
BLOCK-READ
~LOCK-WRITE
These are the preferred names
for the installation dependent code
to read and write one block to the
disc.
BRANCH
BUFFER
c!
c,
C2,LO
The run-time proceedure to unconditionally branch. .An in-line offset
is added to the interpretive pointer
IP to branch ahead or back.
BRANCH
is compiled by ELSE, AGAIN, REPEAT.
addr
n
Obtain the n~xt memory buffer, assigning it to block n.
If the contents of the buffer is marked as .updated, it is written to the disc
The block is not read from the disc.
The address left is the first cell
within the buffer for data st~rage.
b addr
Store 8 bits at address.
On word
addressing computers, further specification is necessary regarding byte
addressing.
b
Store 8 bits of b into the next
available dictionary byte, advancing
the dictionary pointer.
This is only
available on byte addressing computers, and should be used with
caution on byte addressing minicomputers.
LO
CR
Transmit a carriage ret~rn and line
feed to the selected output device.
CREATE
C@
addr
b
Leave the 8 bit contents of memory
address.
On word addressing computers, further specification is needed
regarding byte addressing.
CFA
pfa
cfa
Convert the .parameter field address
of a definition to its code field
address.
CMOVE
from
to count
Move the specified quantity of bytes
beginning at address from to address
to.
The contents of address from
is moved first proceeding toward high
memory.
Further specification is
necessary dn word addressing computers.
A defining word used in the form:
CREATE ecce
by such words as CODE and CONSTANT
to create a dictionary header for
a Forth definition.
The code field
contains the address of the words
parameter field.
The new word is
created in the CURRENT vocablary.
.CSP
addr
U
A user variable temporarily storing
the stack pointer position, for
compilation error checking.
D+
dl
d2 --- dsum
Leave the double number sum of two
double numbers.
D+-
dl
n
d2
Apply the sign of n to the double
number dl, leaving it as d2.
COLD
The cold start proceedure to adjust
the dictionary pointer to the minimum standard and restart via ABORT.
May be called from the terminal to
remove application programs and
restart.
FORTH INTEREST GROUP •
o • o •
D.
d
L1
Print a signed double number from a
32 bit two's complement value. The
high-order 16 bits are most accessable on the stack.
Conversion is
performed according to the current
BASE~
A blank follows.
Pronounced
D-dot.
P. 0. Box 1105 •••• • San Carlos, Ca. 94070
II
D.R
d
DO
n
Print a signed double number d right
aligned in a field n characters wide.
DABS
ud
d
Leave the absolute value ud of a
double number.
LO
DECINAL
Set the numeric conversion BASE for
decimal input-output.
Ll
DEFINITIONS
Used in the form:
DEFINITIONS
ecce
Set the CURRENT vocabulary to the
In the example,
CONTEXT vocabulary.
executing vocabulary name ecce made
it the CONTEXT vocabulary and executing DEFINITIONS made both specify
vocabulary ecce.
DIGIT
(ok)
tf
n2
nl
c
(bad)
ff
nl
c
Converts the ascii character c (using
base nl) to its binary equivalent n2,
If the
accompanied by a true flag.
conversion is invalid, leaves only
a false flag.
urrent value of the index to the
+LOOP, LEAVE.
LOOP,
I,
See
stack.
When compiling within the colondefinition, DO compiles (DO), leaves
the following address addr and n for
later error checking.
DOES>
LO
A word which defines the run-time
action within a high-level defining
DOES> alters the code field
word.
and first parameter of the new word
to execute the sequence of compiled
Used
word addresses following DOES>.
in combination with <BUILDS. When the
DOES> part executes it begins with
the address of the first parameter
This
of the new word on the stack.
allows interpretation using this
Typical uses
area or its contents.
include the Forth assembler, multidiminsional arrays, and compiler
generation.
DP
U,L
addr
A user variable, the dictionary
pointer, which contains the address
of the next free memory above the
dictionary. The value may be read by
HERE and altered by ALLOT.
DPL
U,LO
addr
A user variable containing the number
of digits to the right of the decimal
It may also
on double integer input.
be used hold output column location
of a decimal point, in user generated
The default value on
formating.
single number input is -1.
DRO
DRl
Installation dependent commands to
select disc drives, by preseting
The contents of OFFSET is
OFFSET.
added to the block number in BLOCK
Offset
to allow for this selection.
is supressed for error text so that
is may always originate from drive 0.
DLIST
List the names of the dictionary
entries in the CONTEXT vocabulary.
DLITERAL
DMINUS
(executing)
d
d
P
(compiling)
d
If compiling, compile a stack double
Later executnumber into a literal.
ion of the definition containing the
literal will push it to the stack. If
executing, the number will remain on
the stack.
(execute)
n2
nl
P,C2,LO
(compile)
n
addr
Occurs in a colon-definition in form:
DO
LOOP
+LOOP
DO
At run time, DO begins a sequence
with repetitive execution controlled
by a loop limit nl and an index with
DO removes these
initial value n2.
Upon reaching LOOP
from the stack.
the index is incremented by one.
Until the new index equals or exceeds
the limit, execution loops back to
just after DO; otherwise the loop
~arameters are discarded and executBoth nl and n2
ion continues ahead.
are determined at run-time and may be
the result of other operations.
Within a loop ' I ' will copy the
d2
dl
Convert dl to its double number two's
complement.
FORTH INTEREST GROUP ·····P.O. Box 1105
oooo•
San Carlos, Ca. 94070
;2_;
DROP
LO
n
END IF
Drop the number from the stack.
DUMP
DUP
LO
addr n
Print the contents of n memor~
locations beginning at addr.
Both
addresses and contertts are shown in
the current numeric base.
n
n
LO
n
Duplicate the value on the stack.
ELSE
addrl
At compile-time,
ENDIF computes the
forward branch offset from addr to
HERE and stores it at addr.
n is
used for error tests.
nl
addr2
n2
(compiling)
P,C2,LO
Occurs within a colon-definition
in the form:
IF
ELSE
ENDIF
At run•time, ELSE executes after the
true part following IF.
ELSE forces
execution to skip over the following
false part and resumes execution
after the ENDIF. It has no stack
effect.
ERASE
addr n
Clear a region of memory to zero from
addr over n addresses.
ERROR
line
in blk
Execute error notification and restart of system.
WARNING is first
examined.
If 1, the text of line n,
relative to screen 4 of drive 0 is
printed.
This line number may be
positive or negative, and beyond just
screen 4.
If WARNING•O, n is just
printed as a message number (non disc
installation).
If WARNING is -1,
the definition (ABORT) is executed,
which executes the system ABORT. The
user may cautiously modify this
execution by altering (ABORT).
fig-FORTH saves the contents of IN
and BLK to assist in determining the
location of the error.
Final action
is execution of QUIT.
EXECUTE
addr
Execute the definition whose code
field address is on the stack. The
code field address is also called
the compilation address.
EXPECT
addr
count
LO
Transfer characte~s from the terminal
to address, u_ntil a "return" or the
count of characters have been received.
One or more nulls are added
at the end of the text.
FENCE
addr
u
A user variable containing an
address below which FORGETting is
trapped.
To forget below this point
the user must alter the contents of
FENCE.
FILL
addr
quan b
Fill memory at the address with the
specified quantity of bytes b.
At compile-time ELSE emplaces BRANCH
reserving a branch offset, leaves
the address addr2 and n2 for error
testing.
ELSE also resolves the
pending forward branch from IF by
calculating the offset from addrl to
HERE and storing at addrl.
EMIT
c
Transmit ascii character c to the
selected output device.
OUT is
incremented for each charact~r
output.
LO
EMPTY-BUFFERS
LO
Mark all block-buffers as empty, not
necessarily affecting the contents.
Updated blocks are not written to the
disc.
This is also an initialization
proceedure before first use of the
disc.
ENCLOSE
END
addr n
(compile)
P,CO,LO
Occurs in a colon-definition in fot"m:
IF
END IF
IF
ELSE
ENDIF
At run-time, ENDIF serves only as the
destination of a forward branch from
IF or ELSE.
It marks the conclusion
of the conditional structure.
THEN
is another name for ENDIF.
Both
names are supported in fig-FORTH. See
also IF and ELSE.
addrl
c
ddrl
nl
n2
n3
The text scanning primitive used by
WORD.
From the text address addrl
and an ascii delimiting character c,
is determi.ned the byte offset to the
first non-delimiter character nl,
the offset to the first delimiter
after the text n2, and the offset
~o the first character not included.
This proceedure will not process past
an ascii 'null', treating it as an
unconditional delimiter.
P,C2,LO
This is an 'alias' or duplicate
definition for UNTIL.
FIRST
n
A constant that leaves the address
of the first (lowest). block buffer.
FORTH INTEREST GROUP
o o o o o
P. 0. Box 1105
u
.. o
San Carlos, Ca. 94070
ji]
FLD
addr
u
A user variable for control of number
output field width.
Presently unused in fig-FORTH.
FORGET
E,LO
Executed in the form:
FORGET ecce
Deletes definition named ecce from
the dictionary with all entries
physically following it.
In figFORTH, an error message will occur if
the CURRENT and CONTEXT vocabularies
are no~ currently the same.
FORTH
P,Ll
The name of the primary vocabulary.
Execution makes FORTH the CONTEXt
vocabulary.
Until additional user
vocabularies are defined, new user
definitions become a part of FORTH.
FORTH is immediate, so it will execute during the creation of a colondefinition, to select this vocabulary
at compile time.
HERE
IF
IMMEDIATE
Mark the most reseritly made definition so that when encountered at
compile time, it will b~ executed
rather than being compiled. i.e. the
precedence bit in its header is set•
This method allows definitions to
handle unusual compiling situations,
rather than build them into the
fundamental compiler.
The user may
force compilation of an immediate
definition by preceeding it with
[COMPILE).
LO
Se~
the numeric conversion base to
sixteen (hexadecimal).
HLD
HOLD
I
ID.
addr
LO
A user variable that holds the addr~
ess of the latest character of text
during numeric output conversion.
c
LO
Used between <# and #> to insert
an ascii character into a pictured
numeric output string.
e.g.
2E HOLD
will place a
decimal point.
n
C,LO
Used within a DO-LOOP to copy the
loop index to the stack.
Other
use is implementation dependent.
See R.
addr
Print a definition's name from its
name field address.
(run-time)
addr n
(compile)
P,C2,LO
Occurs is a colon-definition in form:
IF (tp) •••
ENDIF
IF ( t p) •• • ELSE ( f p) • • • END IF
At run-time, IF selects execution
based on a boolean flag.
If f is
true (non-zero), execution continues
ahead thru the true part•
If f is
false (zero), execution skips till
just after ELSE to execute the false
part.
After either part, execution
resumes after ENDIF.
ELSE and its
false part are optional.; if missing,
false execution ski~s to just after
END IF.
At compile-time IF compiles OBRANCH
and reserves space for an offset
at ad.dr.
addr and n are used later
for resolution of the offset and
error testing.
addr
LO
Leave the address of the next available dictionary location.
HEX
f
IN
addr
LO
A user variable containing the byte
offset within the current inp~t text
buffer (terminal or disc) from which
the next text will be accepted.
WORD
uses and moves the value of IN.
INDEX
from to
Print the first line of each screen
over the range from, to.
This is
used to view the comment lines of an
area of text on disc screens.
INTERPRET
The outer ~ext interpreter whi~h
sequentially executes or compiles
text from the input stream (terminal
or disc) depending on STATE.
If the
word name cannot be found after
a search of CONTEXT and then CURRENT
it is converted to a number according
to the current base.
That also failing, an error message echo~ng the
name with a " ?" will be given.
Text input will be taken according to
the convention for WORD. If a decimal
point is found a~ part of a number,
a double number value will be left.
The decimal point has no other purpose than to force this action.
See NUMBER.
FORTH INTEREST GROUP · · · · P. 0. Box 110 5
o
o • o o o
San Carlos, Ca. 94070
KEY
c
Leave the ascii value of the next
terminal key struck.
LATEST
addr
Leave the name field address of the
topmost word in the CURRENT vocabulary.
LEAVE
C,LO
Force termination of a DO-LOOP at the
next opportunity by setting the loop
limit equal to the current value of
the index.
The index itself remains
unchanged, and exeeution prodeeds
normally until LOOP or +LOOP is
encountered.
LFA
LIMIT
LO
LOOP
At compile-time, LOOP compiles (LOOP)
and uses addr to calculate an offset
to DO.
n is used for error testing.
M*
nl
n2
d
A mixed magnitude math operation
which leav~s the double numb~r signed
product of two signed number.
M/
d
nl
n2 n3
A mixed magnitude math operator which
leaves the signed remainder n2 and
signed quotient n3, from a double
number dividend and divisor nl. T~e
remainder takes its sign from the
dividend.
M/MOD
udl
u2
u3 ud4
An unsigned mixed magnitude math
operation which leaves a double
quotient ud4 and remainder u3, from
a double dividend tidl and single
divisor u2.
pf a
1f a
Convert the parameter field address
of a dictionary definition to its
link field address.
n
A constant leaving the address just
above the highest memory available
for a disc buffer.
Usually this is
the highest system memory.
LIST
n
LO
Display the ascii text of screen n
on the selected output device.
SCR
contains the screen number during and
after this process.
LIT
n
C2,LO
Within a colon-definition , LIT is
automatically compiled before each
16 bit literal number encountered in
input text.
Later execution of LIT
causes the con~ents of the next
dictionary address to be pushed to
the stack.
LITERAL
LOAD
n
(compiling)
P,C2,LO
If compiling, then compile the stack
value n as a 16 bit literal.
This
definition is immediate so that it
~ill execute during a colon definition.
The intended use is:
: xxx
[ calculate ]
LITERAL
Compilation is suspended for the
compile time calculation of a value.
Compilation is reusumed and LITERAL
compiles this value.
n
LO
Begin interpretation of screen n.
Loading will terminate at the end of
the screen or at ;S.
See ;S and
-->.
addr n -~(compiling) P,C2,tO
Occurs in a colon-definition in form:
DO
LOOP
At run-time, LOOP selectively c6ntrols branching back to the corresponding DO based on the loop index and
limit.
The loop index is incremented
by one and compared to the limit. The
branch back to DO occurs until the.
index equals or exceeds the limit;
at that time, the parameters are
discarded and execution continues
ahead.
MAX
MESSAGE
nl n2
max
LO
Leave the greater of two numbers.
n
Print on the selected output device
th·e text of 1 ine n relative to screen
4 of drive 0.
n may be positive or
negative.
MESSAGE may be used to
print incidental text such as report
headers.
If WARNING is zero, the
message will. simply be printed as
a number (disc un-available).
MIN
nl
n2
min
Leave the smaller of two numbers.
LO
MINUS
nl
n2
Leave the two's complement of a
number.
LO
MOD
nl
n2
mod
LO
Leave the remainder of nl/n2, with
the same sign as nl. ·
MON
Exit to the system monitori leaving
a re-entry to Forth, if possible.
FORTH INTEREST GROUP · · · · · P. 0. Box 110 5
o o • • •
San Carlos, Ca. 94070
MOVE
addrl
addr2
n
Move the contents of n memory cells
(16 bit contents) beginning at addrl
into n cells beginning at addr2.
The contents of addrl is moved first.
This definition is •ppropriate on
on word addressing computers.
PAD
LO
addr
Leave the address of the text output
buffer, which is a fixed offset above
HERE.
PFA
nfa
pfa
Convert the name field address of
a compiled definition to its para•
meter field address.
NEXT
This is the inner interpreter that
uses the interpretive pointer IP to
execute compiled Forth definitions.
It {s not dire~tly executed but is
the return point for all code proceedures.
It acts by fetching the
address pointed by IP, storing this
value in register w.
It then jumps
to the address pointed to by the
address ~dinted to by w. W points to
the code field of a definition which
contains the address of· the code
which executes for that definition.
This usage of indirect threaded code
is a major contributor to the power,
portability, and extensibility of
Forth.
Locations of IP and W are
computer specific.
POP
The code sequence to remove a stack
value and return to NEXT.
POP is
not directly executable, but is a
Forth re-entry point after machine
code.
PREV
addr
A variable containing the address of
the disc buffer most recently referenced.
The UPDATE command marks
this buffer to be later written to.
disc.
PUSH
NFA
pfa
nfa
Convert the parameter field address
of ,a definiti.on to its name field.
NUMBER
addr
d
Convert a character string left at
addr with a preceeding count, to
a signed double number, using the
current numeric base.
If a decimal
point is encountered in the text, its
position will be given in DPL, but
no other effect occurs. If numeric
conversion is not possible, an error
message will be given.
This code sequence pushes machine
registers to the computation stack
and returns to NEXT.
It is not
directly executable, but is a Forth
re-entry point after machine code~
PUT
This code sequence stores machine
register contents over the topmost
computation stack value and returns
to NEXT.
It is not directly executable, but is a Forth re-entry point
after machine code.
QUERY
OFFSET
u
addr
A·user variable which may contain
a block offset to disc drives.
The
contents of OFFSET is added to the
stack number by BLOCK. Messages
by MESSAGE are independent of OFFSET.
See BLOCK,
DRO,
DRl,
MESSAGE.
OR
nl
n2
or
LO
Leave the bit~wise logical or of two
16. bit values.
OUT
addr
u
A user variable that contains a value
incremented by EMIT.
The user may
alter and examine OUT to control
display formating.
OVER
LO
nl
n2 --- · nl
n2 nl
Copy ~he second stack value, placing
it as the new top.
FORTH INTEREST GROUP
o o o • •
Input 80 characters of text (or until
a "return") from the operators
terminal.
Text is positioned at the
address contained in TIB with IN
set to zero.
QUlT
R
Ll
Clear th• return stack, stop compilation, and return control to the
operators terminal.
No message
is given.
n
Copy the top of the return stack to
the computation stack.
Rfl
addr
A user variable which may co~tain
the location of an editing cursor,
or other file related function.
P. 0. Box 110 5 · · · · · San Carlos, Ca. 94070
U
SMUDGE
R/W
R>
RO
REPEAT
addr
blk
f
The fig-FORTH standard disc readwrite linkage.
addr specifies the
source or destination block buffer,
blk is the sequential number of
the referenced block; and f is a
flag for f•O write and f•l read.
R/W determines the location on mass
storage, performs the read-write and
performs any error checking.
n
LO
Remove the top value from the return
stack and leave it on the computation
stack.
See
>R and R.
ROT
SP!
A computer dependent proceedure to
initialize the stack pointer from
so.
SP@
addr
A computer dependent pt;oceed,ure to
return the address of the stack
position to the top of the stack,
as it was before SP@ was executed.
(e.g. 1 2 SP@
@
would
type 2
2 1)
SPACE
LO
Transmit an ascii blank to the output
device.
SPACES
n
LO
Transmit n ascii blanks to the output
device.
STATE
addr
LO,U
A user variable containg the compilation state.
A non-zero value
indicates compilation.
The value
itself may be implementatio n dependent.
SWAP
nl
n2
n2 nl
LO
Exchange the top two values on the
stack.
u
addr
A user variable containing the
initial location of the return stack.
Pronounc~d R-zero.
See RP!
addr
n
(compiling)
P.C2
Used within a colon-defini tion in the
form:
BEGIN
WHILE
REPEAT
At run-time, REPEAT forces an
unconditiona l branch back to just
after the correspoindin g BEGIN.
At compile-time , REPEAT compiles
BRANCH and the offset from HERE to
addr.
n is used for error testing.
\.
Used durirg word definition to toggle
the "smudge bit" in a definitions'
name field.
This prevents an uncompleted definition from being found
during dictionary searches, until
compiling is completed without error.
n1
n2
n2
n3
n3
nl
LO
Rotate the top three values on the
stack, bringing the third to the top.
RP!
A computer dependent proceedure to
initialize the return stack pointer
from user variable RO.
s->D
n
d
Sign extend a single number to form
a double number.
so
addr
u
A user variable that contains the
initial value for the stack pointer.
Pronounced S-zero.
See SP!
SCR
SIGN
addr
u
A user variable containing the screen
number most recently reference by
LIST.
n d
d
LO
Stores an ascii "-" sign just before
a converted numeric output string
in the text output buffer when n is
negative.
n is discarded, but double
number d is maintained.
Must be
used between
<#
and
#>.
FORTH INTEREST GROUP
o • o o •
TASK
A no-operation word which can mark
the boundary between applications .
By forgetting TASK and re-compiling ,
an application can be discarded in
its entirety.
THEN
An alias for ENDIF.
P,CO,LO
TIB
addr
u
A user variable containing the address of the terminal input buffer.
TOGGLE
addr .b
Complement the contents of addr by
the bit pattern b.
TRAVERSE
addrl
n
addr2
Move across the name field of a
fig-FORTH variable length name field.
addrl is the address of either the
length byte or the last letter.
If n•l, the motion is toward hi memory;
if n•-1, the motion is toward
low memory. The addr2 resulting is
address of the other end of the name.
P. 0. Box 110 5
o • • • •
San Carlos, Ca. 94070
TRIAD
scr
Display on the selected output device
the three screens which include that
numbered scr, begining with a screen
evenly divisible by three.
Output
is suitable for source text records,
and includes a reference line at the
bottom taken fr~m line 15 of screen4.
TYPE
addr count
LO
Transmit count characters from addr
to the selected output device.
U*
ul
u2
ud
Leave the unsigned double number
product of t•o unsigned numbers.
U/
ud
u1
u2 u3
Leave the unsigned remainder u2 and
unsigned quotient u3 from the unsign•
ed double dividend ud and unsigned
divisor ul.
UNTIL.
f
(run-time)
addr n --(compile)
P,C2,LO
Occurs within a colon-definition in
the form:
BEGIN
UNTIL
At run-time, UNTIL controls the conditional branch back to the corresponding BEGIN.
If f is false, execution returns to just after BEGIN;
if true, execution continues ahead.
\
At compile-time, UNTIL compiles
(O~RANCH) and an offset from HERE
to addr.
n is used for error tests.
UPDATE
LO
Marks the most recently referenced
block (pointed to by PREV) as
altered.
The block will subsequently
be transferred automatically to disc
should its buffer be required for
storage of a different block.
USE
addr
A variable containing the address of
the block buffer to use next, as the
least recently written.
USER
n
LO
A defining word used in the form:
n USER ecce
which ~reates a user variable ecce.
The parameter field of ecce contains
n as a fixed offset relative to
the user pointer register UP for
this user variable.
When ecce is
later executed, it places the sum of
its offset and the user area base
address on the stack as the storage
address of that particular variable.
VARIABLE
E,LU
A defining word used in the form:
n VARIABLE ecce
When VARIABLE is executed, it creates
the definition ecce with its parameter field initialized to n.
When
ecce is later executed, the address
of its parameter field (containing n)
is left on the stack, so that a fetch
or store may access this location.
VOC-LINK
addr
U
A user variable containing the address of a field in the definition of
the most recently created vocabulary.
All vo~abulary names are linked by
these fields to allow control for
FORGETting thru multiple vocabularys.
VOCABULARY
E,L
A defining word used in the form:
VOCABULARY ecce
to create a vocabulary definition
ecce.
Subsequent use of ecce will
make it the CONTEXT vocabulary which
is searched first by INTERPRET.
The
sequence "ecce DEFINITIONS" will
also make ecce th~ CURRENT vocabulary
into which new definitions are
placed.
In fig-FORTH, ecce will be so chained
as to include all definitions of the
vocabulary in which ecce is itself
defined.
All vocabularys ulitmately
chain to ~orth.
By convention,
vocabulary names a.re to be declared
IMMEDIATE.
See VOC-LINK.
VLIST
List the names of the defin1tions in
the context vocabulary.
"Break" will
terminate the listing.
YARNING
addr
u
A user variable containing a value
controlling messages.
If • 1
disc is present, and screen 4 of
drive 0 is the base location for
messages.
If • 0, no. disc is present
and messages will. be presented by
number.
If • -1, execute (ABORT) for
a user specified proceedure.
See MESSAGE, ERROR.
WHILE
f
(run-time)
ad1 n1
adl nl ad2 n2
P,C2
Occurs in a colon-definition in the
form:
BEGIN ••• WHILE (tp) •••
REPEAT
At run-time, WHILE selects conditional execution based on boolean flag f.
If f is true (non-zero), WHILE contintues execution of the true part
thru to REPEAT, which then branches
back to BEGIN.
If f is false (zero),
execution skips to just after REPEAT,
exiting the structure.
At compile time, WHILE emplaces
(OBRANCH) and leaves ad2 of the reserved offset.
The stack values will
be resolved by REPEAT.
FORTH INTEREST GROUP ···· · P. 0. Box 1105 ····· San Carlos, Ca. 94070
;S
WIDTH
addr
U
In fig-FORTH, a user variable containing the maximum number of letters
saved in the compilation of a
definitions• name.
It must be 1 thru
31, with a default value of 31.
The
name character count and i~s natural
characters are saved, up to the
value in WIDTH.
The value may be
changed at any time within ~he above
limits.
WORD
LO
c
Read the next text characters from
the input stream being interpreted,
until a delimiter c is found, storing
the packed character string begining·
at the dictionary buffer HERE.
WORD
leaves the character count in the
first· byte, the characters, and ends
with two or more blank~. Leading
occurances of c are ignored.
If BLK
is ~ero, text is taken from the
terminal input buffer, otherwise from
the disc block stored, in BLK.
See BLK, IN.
X
This is pseudonym for the "nu~l"
or dictionary entry for a name of
one character of ascii null.
I~
is the execution proceedure to terminate interpretation of a line of
text from the terminal or within
a disc buffer, as both buffers always
have a null a~ the end.
XOR
nl
n2
xor
Ll
Leave the bitwise logical excluaiveor of two values.
P,I,.l
Used in a colon-definition in form:
: xxx
[ words
J
more
;
Suspend compilation.
The words after
[ are executed, not compiled.
This
allows calculation or compilation
exceptions before resuming compilation with].
See LITERAL, ].
fCOMPILE]
P,C
Used in a colon-definition in form:
xxx
[COMPILE]
FORTH
;
[COMPILE]
will force ~he compilation
of an immediate defininition,
that would otherwise execute
during compilation.
The above
example will select the FORTH
vocabulary when xxx executes, rather
than at compile time.
Ll
Resume compilation, to the completion
of a colon-definition • . See [.
FORTH INTEREST GROUP . ·
o o o •
P. 0. Box 1105 ···· · San Carlos, Ca. 94070
SCR
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(
'··
SCR
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
II
3
**********************
fig-FORTH
MODEL
**********************
Through the courtesy of
FORTH INTEREST GROUP
P. O. BOX 1105
SAN CARLOS, CA. 94070
RELEASE 1
WITH COMPILER SECURITY.
AND
VARIABLE LENGTH NAMES
Further distribution must include the above notice.
II 4
(
ERROR MESSAGES
)
EMPTY STACK
DICTIONARY FULL
HAS INCORRECT ADDRESS MODE
ISN'T UNIQUE
DISC RANGE ?
FULL STACK
DISC ERROR
FORTH INTEREST GROUP
MAY 1, 19 79
SCR II 5
0 (
ERROR MESSAGES
)
1 COMPILATION ONLY, USE IN DEFINITION
2 EXECUTION ONLY
3 CONDITIONALS NOT PAIRED
4 DEFINITON NOT FINISHED
5 IN PROTECTED DICTIONARY
6 USE ONLY WHEN LOADING
7 OFF CURRENT EDITING SCREEN
8 DECLARE VOCABULARY
9
10
11
12
13
14
15
FORTH INTEREST GROUP
MAY 1, 19 7 9
( PUSH FOLLOWING LITERAL TO STACK
CODE LIT
( PUSH ACCUM AS HI-BYTE, ML STACK AS LO-BYTE
LABEL PUSH
( REPLACE BOTTOM WITH ACCUM. AND ML STACK
l.ABEL PUT
( EXECUTE NEXT FORTH ADDRESS, MOVING IP
l.ABEL NEXT
( MAKE SILENT WORD
,
HERE 2+
<CLIT>
HERE
( MOVE # ITEMS FROM STACK TO 'N' AREA OF Z-PAGE
LABEL SETUP
( EXECUTE A WORD BY ITS CODE FIELD
CODE EXECUTE
{ ADDRESS ON THE STACK
{ ADJUST IP BY IN-LINE 16 BIT LITERAL
CODE BRANCH
{ IF BOT IS ZERO, BRANCH FROM LITERAL
CODE OBRANCH
{ INCREMENT LOOP INDEX, LOOP UNTIL => LIMIT
CODE (LOOP)
{ INCREMENT INDEX BY STACK VALUE +/CODE (+LOOP)
( MOVE TWO STACK ITEMS TO RETURN STACK
CODE (DO)
( COPY CURRENT LOOP INDEX TO STACK
CODE I
( CONVERT ASCII CHAR-SECOND, WITH BASE-BOTTOM
CODE DIGIT
( IF OK RETURN DIGIT-SECOND, TRUE-BOTTOM;
( OTHERWISE FALSE-BOTTOM.
( HERE, NFA ••• PFA, LEN BYTE, TRUE; ELSE FALSE
CODE (FIND)
( ENTER WITH ADDRESS-2, DELIM-1. RETURN WITH
CODE ENCLOSE
( ADDR-4, AND OFFSET TO FIRST CH-3, END WORD-2, NEXT CH-1
{ PRINT ASCII VALUE ON BOTTOM OF STACK
CODE EMIT
( ACCEPT ONE TERMINAL CHARACTER TO THE STACK
CODE KEY
( 'BREAK' LEAVES 1 ON STACK; OTHERWISE 0
CODE ?TERMINAL
( EXECUTE CAR. RETURN, LINE FEED ON TERMINAL
CODE CR
( WITHIN MEMORY; ENTER W/ FROM-3, T0-2, QUAN-1
CODE CMOVE
16 BIT MULTIPLIER-I
( 16 BIT MULTIPLICAND-2,
CODE U*
( 32 BIT UNSIGNED PRODUCT: LO WORD-2, HI WORD-I
16 BIT DIVISOR-I
( 31 BIT DIVIDEND-2, -3,
CODE U/
16 BIT QUOTIENT-!
( 16 BIT REMAINDER-2,
( LOGICAL BITWISE AND OF BOTTOM TWO ITEMS
DE AND
{ LOGitAL BITWISE 'OR' OF BOTTOM TWO ITEMS
D~ OR
( LOGICAL 'EXCLUSIVE-OR' OF BOTTOM TWO ITEMS
DE XOR
( FETCH STACK POINTER TO STACK
DE SP@
( LOAD SP FROM 'SO'
DE SP!
( LOAD RP FROM RO
DE RP!
( RESTORE IP REGISTER FROM RETURN STACK
DE ; S
( FORCE EXIT OF DO-LOOP BY SETTING LIMIT
CODE LEAVE
( TO INDEX
R LDA, R 2+ STA,
XSAVE STX, TSX,
( MOVE FROM COMP. STACK TO RETURN STACK
DE >R
( MOVE FROM RETURN STACK TO COMP. STACK
DE R>
( COPY THE BOTTOM OF RETURN STACK TO COMP. STACK
DE R
( REVERSE LOGICAL STATE OF BOTTOM OF STACK
DE 0=
{ LEAVE TRUE IF NEGATIVE; OTHERWISE FALSE
DE 0<
{ LEAVE THE SUM OF THE BOTTOM TWO STACK ITEMS
DE +
( ADD TWO DOUBLE INTEGERS, LEAVING DOUBLE
DE D+
( TWOS COMPLEMENT OF BOTTOM SINGLE NUMBER
MINUS
( TWOS COMPLEMENT OF BOTTOM DOUBLE NUMBER
DMINUS
( DUPLICATE SECOND ITEM AS NEW BOTTOM
OVER
( DROP BOTTOM STACK ITEM
DROP
( EXCHANGE BOTTOM AND SECOND ITEMS ON STACK
C DE SWAP
( DUPLICATE BOTTOM ITEM ON STACK
C DE DUP
( ADD SECOND TO MEMORY 16 BITS ADDRESSED BY BOTTOM
C DE +!
C lDE TOGGLE
( BYTE AT ~DDRESS-2, BIT PATTERN-I
CODE @
( REPLACE STACK ADDRESS WITH 16 BIT
BOT X) LDA, PHA,
( CONTENTS OF THAT ADDRESS
( REPLACE STACK ADDRESS WITH POINTED 8 BIT BYTE
CODE C@
( STORE SECOND AT 16 BITS ADDRESSED BY BOTTOM
CODE
FORTH INTEREST GROUP
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
1
4
6
8
1
]3
13
13
13
14
4 14
9 14
10 14
1 15
6 15
1 16
*)
16
8
*)
2 17
*)
9 17
*)
1 18
*)
2 18
*)
*)
3 18
1 19
*)
1 20
*)
2 20
*)
*)- 5 21
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*).
*)
*)
7 21
9
11
21
21
1 22
1 23
2 23
1 24
2 24
2 25
6 25
10 25
1 26
5 26
8
26
12 26
1 27
2 27
5 27
8 27
*)
11 2 7
2 28
6 28
*)
*)
1 29
4 29
*)
*)
*)
9 29
*).
*)
*)
*)
*)
*)
*)
*)
*)
*)
MAY 1, 1979
12 2'?
1 30
4 30
7 30
i1 30
2 31
7 31
1 32
2 32
5 32
8 32
..:;/
( STORE SECOND AT BYTE ADDRESSED BY BOTTOM
( CREATE NEW COLON-DEFINITION UNTIL ' ; '
( TERMINATE COLON-DEFINITION
(
WORD
WHICH
LATER CREATES CONSTANTS
CONSTANT
(
WORD
WHICH
LATER CREATES VARIABLES
VARIABLE
( CREATE USER VARIABLE
USER
CR
( ASCII BLANK
20 CONSTANT BL
( TEXT CHARACTERS PER LINE
40 CONSTANT C/L
FIRST
( FIRST BYTE RESERVED FOR BUFFERS
JBEO
CONSTANT
LIMIT
( JUST BEYOND TOP OF RAM
4000
CONSTANT
B/BUF
( BYTES PER DISC BUFFER
80
CONSTANT
( BLOCKS PER SCREEN = 1024 B/BUF /
8
CONSTANT B/SCR
( LEAVES ADDRESS RELATIVE TO ORIGIN
+ORIGIN LITERAL +
REFE~ENCED TO $00AO
HEX
( 0 THRU 5 RESERVED,
( TOP DF EMPTY COMPUTATION STACK
( 06 USER SO )
( TOP OF EMPTY RETURN STACK
( 08 USER RO )
( TERMINAL INPUT BUFFER
OA
USER TIB
( MAXIMUM NAME FIELD WIDTH
OC
USER WIDTH
( CONTROL WARNING MODES
OE
USER WARNING
CR
( BARRIER FOR FORGETTING
10
USER FENCE
( DICTIONARY POINTER
12
USER DP
( TO NEWEST VOCABULARY
14
USER VOC-LINK
( INTERPRETATION BLOCK
16
USER BLK
( OFFSET INTO SOURCE TEXT
18
USER IN
( DISPLAY CURSOR POSITION
lA
USER OUT
1C
USER SCR
( EDITING SCREEN
1E
USER OFFSET
( POSSIBLY TO OTHER DRIVES
20
USER CONTEXT
( VOCABULARY FIRST SEARCHED
22
USER CURRENT
( SEARCHED SECOND, COMPILED INTO
( COMPILATION STATE
24
USER STATE
( FOR NUMERIC INPUT-OUTPUT
26
USER BASE
CR
( DECIMAL POINT LOCATION
28
USER DPL
( OUTPUT FIELD WIDTH
2A
USER FLO
2C
USER CSP
( CHECK STACK POSITION
2E
USER R//
( EDITING CURSOR POSITION
30
USER HLD
( POINTS TO LAST CHARACTER HELD IN PAD
1+
1
( INCREMENT STACK NUMBER BY ONE
+
2+
2
+
( INCREMENT STACK NUMBER BY TWO
HERE
DP @
( FETCH NEXT FREE ADDRESS IN DICT.
ALLOT
DP +!
( MOVE DICT. POINTER AHEAD
HERE.
2 ALLOT
CR ( ENTER STACK NUMBER TO DICT.
'
1
C,
HERE C!
ALLOT
( ENTER STACK BYTE TO D!CT.
MINUS +
( LEAVE DIFF.
SEC - BOTTOM
=
0=
( LEAVE BOOLEAN OF EQUALITY
( LEAVE BOOLEAN OF SEC < BOT
: <
0<
SWAP
( LEAVE BOOLEAN OF SEC ) BOT
<
>
ROT
>R SWAP R>
SWAP
( ROTATE THIRD TO BOTTOM
SPACE
BL
EM! T
CR
( PRINT BLANK ON TERMINAL
-DUP
DUP
IF DUP
END IF
( DUPLICATE NON-ZERO
TRAVERSE
( MOVE ACROSS NAME FIELD
( ADDRESS-2, DIRECTION-I, I.E~ -1=R TO L, +l=L TO R
LATEST
CURRENT @ @
( NFA OF LATEST WORD
LFA
4
( CONVERT A WORDS PFA TO LFA
CFA
2
CR
( CONVERT A WORDS PFA TO CFA
NFA
5
-1
TRAVERSE
( CONVERT A WORDS PFA TO NFA
PFA
1 TRAVERSE 5 +
( CONVERT A WORDS NFA TO PFA
!CSP
SP@ CSP
( SAVE STACK POSITIDN IN 'CSP'
CODE C!
\
FORTH INTEREST GROUP
*)
*)
*)
*)
*)
*)
*)
* )_
*)
*)
*)
*)
*)
*)
*)
*)
12 32
2 33
9 33
1 34
5 34
10 34
4
5
7
8
35
35
35
35
9 35
10 35
13 35
1 36
2 36
3 36
4 36
*)_ 5 36
6 36
*)
7 36
*)
8 36
*)
9 36
*)
*)
10 36
11 36
*)
12 36
*)
13 36
*)
*)_ 1 37
2 37
*)
*)
3 37
*)
*)
4 37
*)
*)
5 37
6 37
*)
*)
7
8
*)
*)
9 37
10 37
*)
1 38
*)
*)
3 38
37
37
2 38
*)
4 38
5 38
6 38
7 38
8 38
*)
9 38
*)
*)
*)
*)
*)
*)
*)
*)
10
. 11
12
13
38
38
38
38
*)
1 39
*)
2 39
6 39
11 39
12 39
13 39
14 39
1 40
*)
*)
*)
*)
*)
*)
HAY 1 ~ 1979
( BOOLEAN-2,
?ERROR
ERROR TYPE-1,
WARN FOR TRUE
STATE @ 0= 11 ?ERROR
?COt-1P
( ERROR IF NOT COMPILING
STATE @ 12
?ERROR
?EXEC
( ERROR IF NOT EXECUTING
13
?ERROR
?PAIRS
( VERIFY STACK VALUES ARE PAIRED
14
?CSP
?ERROR
SP@ CSP @ ; ( VERIFY STACK POSITION
?LOADING
( VERIFY LOADING FROM DISC
COHPILE
( COMPILE THE EXECUTION ADDRESS FOLLOWING
IMMEDIATE
(
0
STATE
( STOP COMPILATION
J
( ENTER COMPILATION STATE
co STATE
SMUDGE
LATEST
( ALTER LATEST WORD NAME
20 TOGGLE
10 BASE
( MAKE HEX THE IN-OUT BASE
HEX
( MAKE DECIMAL THE. IN-OUT BASE
DECIMAL OA BASE
(;CODE)
( WRITE CODE FIELD POINTING TO CALLING ADDRESS
( TERMINATE A NEW DEFINING WORD
;CODE
0 CONSTANT
<BUILDS
( CREATE HEADER FOR 'DOES>' WORD
DOES>
( REWRITE PFA WITH CALLING HI-LEVEL ADDRESS
( REWRITE CFA WITH 'DOES>' CODE
DUP 1+ SWAP C@
COUNT
( LEAVE TEXT ADDR. CHAR. COUNT
TYPE
( TYPE STRING FROM ADDRESS-2, CHAR.COUNT-1
( ADJUST CHAR. COUNT TO DROP TRAILING BLANKS
-TRAILING
( TYPE IN-LINE STRING, ADJUSTING RETURN
( ")
22 STATE @
"
( COMPILE OR PRINT QUOTED STRING
EXPECT
( TERMINAL INPUT MEMORY-2,
CHAR LIMIT-1
X
BLK @
( END-OF-TEXT IS NULL
FILL
( FILL MEMORY BEGIN-3,
QUAN-2,
BYTE-1
ERASE
( FILL MEMORY WITH ZEROS BEGIN-2,
QUAN-1
BLANKS
( FILL WITH BLANKS BEGIN-2, QUAN-1
HOLD
( HOLD CHARACTER IN PAD
HERE
PAD
44 +
( PAD IS 68 BYTES ABOVE HERE
( DOWNWARD HAS NUMERIC OUTPUTS; UPWARD MAY HOLD TEXT
WORD
( ENTER WITH DELIMITER, MOVE STRING TO 'HERE'
(NUMBER)
( CONVERT DOUBLE NUMBER, LEAVING UNCONV. ADDR.
NUHBER
( ENTER W/ STRING ADDR.
LEAVE DOUBLE NUMBER
-FIND
( RETURN PFA-3, LEN BYTE-2, TRUE-1; ELSE FALSE
(ABORT)
GAP
( ABORT )
( USER ALTERABLE ERROR ABORT
ERROR
( WARNING:
-1=ABORT, O=NO DISC, !=DISC
WARNING
@ 0<
( PRINT TEXT LINE REL TO SCR #4
ID.
( PRINT NAME FIELD FROM ITS HEADER ADDRESS
CREATE
( A SMUDGED CODE HEADER TO PARAM FIELD
( WARNING IF DUPLICATING A CURRENT NAME
[COMPILE]
( FORCE COMPILATidN OF AN IMMEDIATE WORD
LITERAL
( IF COMPILING, CREATE LITERAL
DLITERAL
( IF COMPILING, CREATE DOUBLE LITERAL
?STACK
( QUESTION UPON OVER OR UNDERFLOW OF STACK
INTERPRET
· ( INTERPRET OR COMPILE SOURCE TEXT INPUT WORDS
IMMEDIATE
( TOGGLE PREC~ BIT OF LATEST CURRENT WORD
VOCABULARY
( CREATE VOCAB WITH 'V-HEAD' AT VOC INTERSECT.
VOCABULARY FORTH
IMMEDIATE
( THE TRUNK VOCABULARY
DEFINITIONS
( SET THE CONTEXT ALSO AS CURRENT VOCAB
: (
( SKIP INPUT TEXT UNTIL RIGHT PARENTHESIS
: QUIT
( RESTART,
INTERPRET· FROM TERHINAL
: ABORT
( WARM RESTART, INCLUDING REGISTERS
CODE COLD
( COLD START, INITIALIZING USER AREA
CODE S->D
( EXTEND SINGLE INTEGER TO DOUBLE
+0< IF MINUS ENDIF ;
( APPLY SIGN TO NUMBER BENEATH
: D+( APPLY SIGN TO DOUBLE NUMBER BENEATH
: ABS
DUP +( LEAVE ABSOLUTE VALUE
.
..
FORTH INTEREST GROUP
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
3 40
6 40
8 40
10 40
12 40
14 40
2 41
5 41
7 41
9 41
11 41
13 41
2 42
6 42
2 43
4
5
43
43
1 44
2 L1 4
5 44
8 44
12 44
2 45
11 45
1 46
*)
4 46
*)
*)
*)
*)
10 46
13 46
14 46
*)
1 47
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
*)
HAY 1, I 9 7 9
7 46
I 4A
6 l! 8
12 48
2 49
4 49
5 49
9
49
2 50
3
2
5
8
50
51
51
51
13 51
2 52
1 53
4 53
9 53
1 1 53
14 53
2 54
7 54
1 55
1 56
4 56
6 56
9 56
10 56
( DOUBLE INTEGER ABSOLUTE VALUE *)
( LEAVE SMALLER OF TWO NUMBERS *)
12 56
( LEAVE tARGET OF TWO NUMBERS *)
14 56
( LEAVE SIGNED DOUBLE PRODUCT OF TWO SINGLE NUMBERS *)
1 57
( FROM SIGNED DOUBLE-3-2, SIGNED DIVISOR-I *)_ 3 57
( LEAVE SIGNED REMAINDER-2, SIGNED QUOTIENT-I *)
4 57
U*
DROP
;
( SIGNED PRODUCT *)
7 57
: *
>R
S->D
R>
M/
( L!AVE REM-2, QUOT-I *)
8 57
/MOD
}MOD SWAP DROP
( LEAVE QUOTIENT *)_ 9 57
I
/MOD
DROP
CR
( LEAVE REMAINDER *)
IO 57
MOD
{ TAKE RATION OF THREE NUMBERS, LEAVING *)
I1 57
*/MOD
>R
M*
R>
M/
( REM-2, QUOTIENT-! *)
12 57
*/
*/MOD
SWAP
DROP
( LEAVE RATIO OF THREE NUMBS *)
13 57
M/MOD
(DOUBLE, SINGLE DIVISOR •••
REMAINDER, DOUBLE *)
I4 57
FIRST
VARIABLE
USE
( NEXT BUFFER TO USE, STALEST *)
I 58
FIRST
VARIABLE
PREV
( MOST RECENTLY REFERENCED BUFFER *)_ 2 58
+BUF
( ADVANCE ADDRESS-I TO NEXT BUFFER. RETURNS FALSE *)
4 58
84 ( I.E. B/BUF+4 )
+
DUP
LIMIT
=
( IF AT PREV *)- 5 58
UPDATE .
( MARK THE BUFFER POINTED TO BY PREV AS ALTERED *)_ 8 58
EMPTY-BUFFERS
( CLEAR BLOCK BUFFERS; DON'T WRITE TO DISC *)
11 58
DRO
0
OFFSET
( SELECT DRIVE #0 *)
14 58
DR1
07DO
OFFSET
-->
( SELECT DRIVE #1 *)
15 58
BUFFER
( CONVERT BLOCK# TO STORAGE ADDRESS *)
1 59
BLOCK
( CONVERT BLOCK NUMBER TO ITS BUFFER ADDRESS *)
1 60
(LINE)
( LINE#, SCR#, •••
BUFFER ADDRESS, 64 COUNT*)
2 6I
.LINE
(LINE#,
SCR#,
•••
PRINTED*)
6 61
: MESSAGE
( PRINT LINE RELATIVE TO SCREEN #4 OF DRIVE 0 *)
9 61
LOAD
( INTERPRET SCREENS FROM DISC *)
2 62
-->
( CONTINUE INTERPRETATION ON NEXT SCREEN *)
6 62
6900
CONSTANT
DATA
( CONTROLLER PORT *)
1 65
6901
CONSTANT
STATUS
( CONTROLLER PORT *)
2 65
: #HL
( CONVERT DECIMAL DIGIT FOR DISC CONTROLLER *)~ 5 65
CODED/CHAR
( TEST CHAR-1. EXIT TEST BOOL-2, NEW CHAR-1 *)
1 66
: ?DISC
( UPON NAK SHOW ERR MSG, QUIT.
ABSORBS TILL *)
7 66
1 D/CHAR
>R
0=
( EOT, EXCEPT FOR SOH *)
8 66
CODE BLOCK-WRITE
( SEND TO DISC FROM ADDRESS-2,
COUNT-1 *)- 1 67
2 # LDA,
SETUP JSR,
(WITH EOT.AT END *)
2 67
CODE BLOCK-READ
( BUF.ADDR-1. EXIT AT 128 CHAR OR CONTROL *)
2 68
( C
I TO READ, 0 TO WRITE *)
3 69
R/W
( READ/WRITE DISC BLOCK *)
4 69
( BUFFER ADDRESS-3, BLOCK #-2, l=READ O=WRITE *)
5 69
,
( FIND NEXT WORDS PFA; COMPILE IT, IF COMPILING *)
2 72
FORGET
( FOLLOWING WORD FROM .CURRENT VOCABULARY *)
6 72
( SKIP INTERPRETATION OF THE REMAINDER. OF LINE *)
11 72
\
BACK
HERE
,
( RESOLVE BACKWARD BRANCH *)
1 73
D.R
( DOUBLE INTEGER OUTPUT, RIGHT ALIGNED IN FIELD *)
1 76
D.
0
D.R
SPACE
( DOUBLE INTEGER OUTPUT *)
5 76
.R
>R
S->D
R>
D.R
( ALIGNED SINGLE INTEGER *)
7 76
S->D
D.
( SINGLE INTEGER OUTPUT *)
9 76
?
@
( PRINT CONTENTS OF MEMORY *)
11 76
LIST
( LIST SCREEN BY NUMBER ON STACK *)
2 77
INDEX
( PRINT FIRST LINE OF EACH SCR&EN FROM-2,
T0-1 *)
7 77
TRIAD·
( PRINT 3 SCREENS ON PAGE, CONTAINING # ON STACK *)
12 77
VLIST
( LIST CONTEXT VOCABULARY *)
2 78
CREATE
MON
3 79
OK
( CALL MONITOR, SAVING RE-ENTRY TO FORTH *)
DABS
MIN
MAX
M*
M/
DUP
D+-
=
.
.
FORTH
MODEL
IMPLEMENTATION
This model is presented for the serious student as
both an example of a large FORTH program and as a complete
nucleus of FORTH. That is, it is sufficient to run and
to continue to compile itself.
When compiled, the model requires about 2800 bytes of
memory. An expanded version with formatted output and
compiling aids would require about 4000 bytes. A 'full'
implementation usually requires 6000 to 7000 bytes
(including editor, assembler, and disk interface).
The following information consists of word definitions
you will find in the CODE definitions. These are dependent
on the micro-computer used, these being for the MOS Technology
5602.
Note that the notation in the CODE definitions is
'reverse Polish' as is all of FORTH. This means that the
operand comes before the operator. Each equivalent of a
'line' of assembly code has a symbolic operand, then
any address mode modifier, and finally the op-code mnemonic.
(Note that words that generate actual machine code end in
a','
i.e. LDA, ). Therefor:
BOT
1+
LDA
1, X
LDA,
in FORTH would be:
in usual assembler.
And also:
POINTER
STA
)Y
STA,
(POINTER),Y
in FORTH would be:
in usual assembler.
It takes a bit of getting used to, but reverse Polish
assembler allows full use of FORTH in evaluation of
expressions and the easy generation of the equivalent of macros.
GLOSSARY OF FORTH MODEL
IP
address of the Interpretive Pointer in zero-page.
w
address of the code field pointer in zero-page.
N
address of an 8 byte scratch area in zero-page.
XSAVE
address of a temporary register for X in zero-page.
UP
address of
the User Pointer in zero-page.
GLOSSARY OF FORTH MODEL, cont •
•A
speci fy accum ulato r addre ss mode.
#
speci fy imme diate mode for mach ine byte liter als.
speci fy memory index ed addre ss mode.
,X
,Y
)Y
speci fy indir ect memory refer ence by a zero- page regis ter.
BOT
addre ss of high byte of a 16-b it stack item with
,X addre ss mode. X regis ter locat es comp utatio n
stack in zero- page, relat ive to addre ss $0000 .
BOT 1+ addre ss of the low byte of the botto m stack item
with ,X mode prese t.
'
SEC and SEC 1 + addre ss the secon d stack item as for BOT.
X)
TSX,
move the retur n stack point er (whic h is locat ed in
the CPU mach ine stack in page- one) to X regis ter.
R
addre ss of low byte of retur n stack with ,X mode prese t.
addre ss of the n-th byte of the retur n stack with ,X
mode prese t, Note that the low byte is at low
memory, so 1+ gets the high byte, and 3 + gets
the high byte of the secon d item of retur n stack .
addre ss of r6uti ne to repla ce the prese nt comp utatio n
stack high byte from accum ulato r, and put from
the mach ine stack one byte which repla ces the
prese nt low stack byte; conti nue on to NEXT.
R n +
PUT
PUSH
addre ss of routi ne to repea t PUT but creat ing a new
botto m item on the comp utatio n stack .
PUSHOA PUTOA
addre ss of routi ne to place the accum ulato r
at the low stack byte, with the high byte zero.
PUTOA over- write s, while PUSHOA creat es new item.
POP POPTWO
addre ss of routi ne to remov e one or two 16-b it
items from comp utatio n stack .
BINARY addre ss of routi ne to pop one item and PUT the accum
(high ) and ML stack (low) over what was secon d. ulato r
SETUP
addre ss of a routi ne to move 16-b it items to zero- page.
Item quan tity is in accum ulato r.
NEXT
addre ss of the inne r-int erpre ter, to which all
code routi nes must retur n. NEXT fetch es
indir ectly refer red to IP the next comp iled
FORTH word addre ss. It then jumps indir ectly
to point ed mach ine code.
SCR II 6
INPUT-OUTPUT,
0 (
TIM
WFR-780519
1 CODE EMIT
XSAVE STX,
BOT 1+ LDA,
7F II AND,
2
72C6 JSR,
XSAVE LDX,
POP JMP,
3 CODE KEY
XSAVE STX,
BEGIN,
BEGIN,
8 # LDX,
BEGIN,
6E02 LDA,
4
.A LSR,
CS END,
7320 JSR,
5
BEGIN,
731D JSR,
0 X) CMP,
0 X) CMP,
0 X) CMP,
6
0 X) CMP,
0 X) CMP,
6E02 LDA,
.A LSR,
PHP,
TYA,
.A LSR,
7
PLP,
CS IF,
80 II ORA,
THEN,
TAY,
DEX,
0= END,
8
731D JSR,
FF /1 EOR,
7F /1 AND,
0= NOT END,
7F # CMP,
9
0= NOT END,
XSAVE LDX,
PUSHOA JMP,
10 CODE CR XSAVE STX,
728A JSR,
XSAVE LDX, NEXT JMP,
)
11
12 CODE ?TERMINAL
1 II LDA,
6E02 BIT,
0= NOT IF,
13
BEGIN,
731D JSR,
6E02 BIT,
0= END,
INY,
14
TYA,
PUSHOA
JMP,
15 DECIMAL
;S
SCR
0
1
2
3
4
5
6
7
8
9
10
11
12
13
II 7
(
INPUT-OUTPUT,
APPLE
CODE HOME
FC58 JSR,
NEXT JMP,
CODE SCROLL
FC70 JSR,
NEXT JMP,
THEN,
WFR-780730 )
HERE
'
KEY
2
( POINT KEY TO HERE )
FDOC JSR,
7F II AND,
PUSHOA JMP,
HERE
' EMIT
2
( POINT EMIT TO HERE
)
BOT 1+ LDA,
80 II ORA,
FDED JSR,
POP JMP,
HERE
'
CR
2
( POINT CR TO HERE )
FD8E JSR,
NEXT JMP,
HERE
'
?TERMINAL
2
( POINT ?TERM TO HERE )
COOO BIT,
0<
IF,
BEGIN,
COlO BIT,
COOO BIT,
0< NOT END,
INY,
THEN,
TYA,
PUSHOA JMP,
14
15 DECIMAL
SCR
0
1
2
3
4
5
6
;S
II 8
(
INPUT-OUTPUT,
SYM-1
HEX
CODE KEY
8A58 JSR,
7F II AND,
CODE EMIT
CODE CR
BOT 1+ LDA,
834D JSR,
WFR-781015 )
PUSHOA JMP,
'8A47 JSR,
POP JMP,
NEXT JMP,
7
8 CODE ?TERMINAL
( BREAK TEST FOR ANY KEY )
9
8B3C JSR,
CS
10
IF,
BEGIN,
8B3C JSR,
CS NOT
END,
INY,
11
TYA,
PUSHOA JMP,
THEN,
12
13
14
15 DECIMAL
;S
FORTH INTEREST GROUP
MAY 1,
1979
~7
SCR
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
12
( COLD AND WARM ENTRY, USER PARAMETERS
WFR-79APR29 )
ASSEMBLER
OBJECT MEM HEX
NOP,
HERE JMP,
( WORD ALIGNED VECTOR TO COLD )
NOP,
HERE JMP,
( WORD ALIGNED VECTOR TO WARM )
0000 ,
0001 ,
( CPU, AND REVISION PARAMETERS )
0000
( TOPMOST WORD IN FORTH VOCABULARY )
7F
( BACKSPACE CHARACTER )
3BAO
( INITIAL USER AREA )
009E
( INITIAL TOP OF STACK )
01FF
( INITIAL TOP OF RETURN STACK )
0100
( TERMINAL INPUT BUFFER )
001F
( INITIAL NAME FIELD WIDTH )
0001
( INITIAL WARNING = 1 )
0200
( INITIAL FENCE )
0000
( COLD START VALUE FOR DP )
0000
( COLD START VALUE FOR VOC-LINK ) -->
II
SCR II 13
START OF NUCLEUS, LIT, PUSH, PUT, NEXT
0 (
WFR-78DEC26 )
1 CODE LIT
( PUSH FOLLOWING LITERAL TO STACK *)
IP )Y LDA,
2
PHA, IP INC, 0= IF,
IP 1+ INC, THEN,
3
IP )Y LDA,
IP INC, 0= IF,
IP 1+ INC, THEN,
4 LABEL PUSH
( PUSH ACCUM AS HI-BYTE, ML STACK AS LO-BYTE *)
5
DEX, DEX,
6 LABEL PUT
( REPLACE BOTTOM WITH ACCUM. AND ML STACK *)
7
BOT 1+ STA, PLA, BOT STA,
8 LABEL NEXT
( EXECUTE NEXT FORTH ADDRESS, MOVING IP *)
1 II LDY,
9
IP )Y LDA, W 1+ STA,
( FETCH CODE ADDRESS )
10
DEY,
IP )Y LDA, W
STA,
11
CLC,
IP LDA,
2 II ADC,
IP STA,
( MOVE IP AHEAD )
12
CS IF, IP 1+ INC, THEN,
13
W 1 - JMP,
( JUMP !NDIR. VIA W THRU CODE FIELD TO CODE )
14
15 -->
SCR II 14
SETUP
0 (
1
2
3
IP )Y LDA,
HERE 2+
PHA, TYA,
'T' LIT OB +
WFR-790225 )
( MAKE SILENT WORD *)
0== NOT END,
LABEL SETUP
( MOVE II ITEMS FROM STACK TO 'N' AREA OF Z-PAGE *)
.A ASL, N 1 - STA,
BEGIN, BOT LDA, N ,Y STA, INX,
INY,
N 1 - CPY,
7
0= END,
0 H LDY, RTS,
4
5
6
8
9 CODE EXECUTE
10
11
12
13
( EXECUTE A WORD BY ITS CODE FIELD *)
( ADDRESS ON THE STACK *)
BOT LDA, W STA, BOT 1+ LDA, W 1+ STA,
INX,
INX, W 1 - JMP,
14
15 -->
FORTH INTEREST GROUP
MAY 1, 19 7 9
SCR II 15
0 (
BRANCH, OBRANCH
1 CODE BRANCH
2
CLC,
IP )Y LDA,
3
INY,
IP )Y LDA,
4
5
W/16-BIT OFFSET
WFR-79A PR01 )
( ADJUST IP BY IN-LINE 16 BIT LITERAL .*)
IP
ADC,
PHA,
IP 1+ ADC,
IP 1+ STA,
PLA,
IP
STA,
NEXT 2+ JMP,
6 CODE OBRANCH
7
8
9
10
11
12
( IF BOT IS ZERO, BRANCH FROM LITERAL *)
INX,
INX,
FE
,X
LDA,
FF ,X ORA,
,
BRANCH 0• NOT END,
( USE 'BRANCH ' FOR FALSE )
LABEL BUMP:
( TRUE JUST MOVES IP 2 BYTES *)
CLC,
IP LDA,
2 II ADC,
IP STA,
cs IF, IP 1+ INC, THEN, NEXT JMP,
13 -->
14
15
SCR II 16
0 ( LOOP CONTROL
WFR-79MAR20 )
1 CODE (LOOP)
( INCREMENT LOOP INDEX, LOOP UNTIL •> LIMIT *)
2
XSAVE STX,
TSX,
R INC,
0• IF,
R 1+ INC,
THEN,
3
LABEL Ll:
CLC,
R 2+ LOA,
R SBC,
R 3 + LDA,
R 1+ SBC,
4
LABEL L2:
XSAVE LDX,
( LIMIT-IN DEX-1 )
5
• A ASL, '
BRANCH CS END, ( BRANCH UNTIL D7 SIGN•1 )
6
PLA,
PLA,
PLA,
PLA,
BUMP: JMP,
( ELSE EXIT LOOP )
7
8
9
10
11
12
13
14
15
SCR II 17
0 (
(DO-
WFR-79MAR30 )
l
2 CODE (DO)
3
SEC 1+ LDA,
4
BOT 1+ LDA,
5
6 LABEL POPTWO
7 LABEL POP
8
9 CODE I
10
11
12 -->
13
14
PHA,
PHA,
( MOVE TWO STACK ITEMS TO RETURN STACK *)
SEC LDA,
PHA,
BOT LDA,
PHA,
INX,
INX,
INX,
INX,
NEXT JMP,
( COPY CURRENT LOOP INDEX TO STACK *)
( THIS WILL LATER BE POINTED TO 'R' )
15
FORTH INTEREST GROUP
MAY 1, 19 7 9
SCR II I 8
DIGIT
0 (
WFR-781202 )
1 'CODE DIGIT
( CONVERT ASCII CHAR-SECOND, WITH BASE-BOTTOM *)
2
( IF OK RETURN DIGIT-SECOND , TRUE-BOTTOM; *)
3
( OTHERWISE FALSE-BOTTOM. *)
SEC,
4
SEC LDA,
30 # SBC,
0< NOT IF,
5
OA # CMP, ( ADJUST FOR ASCII L~TTER )
6
0< NOT IF,
SEC,
07 II SBC,
OA II CMP,
7
0< NOT IF,
SWAP ( AT COMPILE TIME )
8
THEN,
BOT CMP, ( TO BASE )
9
0< IF,
SEC STA,
1 II LDA,
10
PHA,
TYA,
PUT JMP,
11
( STORE RESULT SECOND AND RETURN TRUE )
THEN,
12
THEN,
THEN,
( CONVERSION FAILED )
TYA,
13
PHA,
INX,
INX,
PUT JMP,
( LEAVE BOOLEAN FALSE )
14
15 -->
SCR
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
II 19
(
FIND FOR VARIABLE LENGTH NAMES
WFR-790225 )
CODE (FIND)
(HERE, NFA ••• PFA, LEN BYTE, TRUE; ELSE FALSE*)
2 # LDA,
SETUP JSR,
XSAVE STX,
BEGIN,
0 II LDY,
N )Y LDA,
N 2+ )Y EOR,
3F II AND,
0•
IF, ( GOOD ) BEGIN, INY, N )Y LDA,
N 2+ )Y EOR,
.A ASL,
0==
IF, ( STILL GOOD ) SWAP
CS ( LOOP TILL D7 SET )
END,
XSAVE LDX,
DEX,
DEX,
DEX,
DEX,
CLC,
TYA,
5 II ADC,
N ADC,
SEC STA,
0 II LDY,
TYA,
N 1+ ADC,
SEC 1+ STA,
BOT 1+ STY,
N )Y LDA,
BOT STA,
1 II LDA,
PHA,
PUSH JMP, ( FALSE )
THEN,
CS
NOT ( AT LAST CHAR? )
IF,
SWAP
THEN,
BEGIN,
INY,
N )Y LDA,
0< END, (TO LAST CHAR)
THEN,
INY,
(TO LINK)
N )Y LDA,
TAX,
!NY,
N )Y LDA,
N 1+ STA,
N STX,
NORA, ( 0 LINK ? ) ·
0= END, ( LOOP FOR ANOTHER NAME )
XSAVE LDX,
0 II LDA, PHA,
PUSH JMP, ( FALSE )
-->
SCR II 20
0 (
ENCLOSE
WFR-780926 )
1 CODE ENCLOSE
( ENTER WITH ADDRESS-2, DELIM-1.
RETURN WITH *)
2
( ADDR-4, AND OFFSET TO FIRST CH-3, END WORD-2, NEXT CH-I *)
3
2 II LDA,
SETUP JSR,
TXA,
SEC,
8 II SBC,
TAX,
4
SEC 1+ STY,
BOT 1+ STY,
( CLEAR HI BYTES )
DEY,
5
BEGIN,
INY,
N 2+ )Y LDA,
( FETCH CHAR )
6
N CMP,
0==
NOT END, . ( STEP OVER LEADING DELIMITERS )
7
BOT 4 + STY,
( SAVE OFFSET TO FIRST CHAR )
8
BEGIN,
N 2+ )Y LDA,
0=
9
IF, ( NULL )
SEC STY, ( IN EW )
BOT STY,
( IN NC )
10
TYA,
BOT 4 + CMP,
0=
11
IF, ( Y=FC )
SEC INC, ( BUMP EW )
THEN,
NEXT JHP,
12
THEN,
SEC STY,
( IN EW )
INY,
N CMP, ( DELIM ? )
13
0= END,
(IS DELIM )· BOT STY, (IN NC)
NEXT JMP,
14
15 -->
FORTH INTEREST GROUP
MAY 1, 19 7 9
.Jo
SCR II 21
0 (
TERMINAL VECTORS
WFR-79M AR30
(
1
THESE WORDS ARE CREATED WITH NO EXECUTION CODE, YET.
2 (
THEIR CODE FIELDS WILL BE FILLED WITH THE ADDRESS OF THEIR
3 (
INSTALL ATION SPECIF IC CODE.
4
5 CODE EMIT
6
7
8
9
10
11
12
13
14
15
CODE KEY
CODE ?TERMIN AL
CODE CR
)
)
)
)
( PRINT ASCII VALUE ON BOTTOM OF STACK *)
( ACCEPT ONE TERMINAL CHARACTER TO THE STACK *)
( 'BREAK ' LEAVES 1 ON STACK; OTHERWISE 0 *)
( EXECUTE CAR. RETURN, LINE FEED ON TERMINAL *)
-->
SCR II 22
0 (
CMOVE,
WFR-79M AR20 )
1 CODE CMOVE
( WITHIN MEMORY; ENTER W/
FROM-3 , T0-2, QUAN-1 *)
2
3 II LDA,
SETUP JSR,
( MOVE 3 ITEMS TO 'N' AREA )
3
BEGIN,
BEGIN,
N CPY,
0=
(DECRE MENT BYTE COUNTER AT 'N'
4
IF,
N 1+ DEC,
0<
( EXIT WHEN DONE )
5
IF,
NEXT JMP,
THEN,
THEN,
6
N 4 + )Y LDA,
N 2+ )Y STA,
INY,
0=
7
END,
( LOOP TILL Y WRAPS, 22 CYCLES /BYTE
)
8
N 5 + INC,
N 3 + INC,
( BUMP HI BYTES OF POINTER S )
9
JMP,
( BACK TO FIRST 'BEGIN ' )
10
11 -->
12
13
14
15
SCR II 2 3
0 (
U*,
UNSIGNED MULTIPL Y FOR 16 BITS
WFR-79 APR08 )
1 CODE U*
( 16 BIT MULTIP LICAND -2,
16 BIT MULTIP LIER-I *)
2
( 32 BIT UNSIGNED PRODUCT: LO WORD-2 , HI WORD-I *)
3
SEC
LDA,
N
STA,
SEC
STY,
4
SEC 1+ LDA,
N 1+ STA,
SEC 1+ STY,
( MULTIP LICAND TO N )
5
10 II LDY,
6
BEGIN,
BOT 2+ ASL,
BOT 3 + ROL,
BOT ROL,
BOT 1+ ROL,
7
( DOUBLE PRODUCT WHILE SAMPLING Dl5 OF MULT
)
8
CS IF, ( SET ) CLC,
9
( ADD MULTIP LICAND TO PARTIAL PRODUCT LOW 24 BITS
10
N
LDA,
BOT 2 + ADC,
BOT 2 + STA,
11
N 1+ LDA,
BOT 3 + ADC,
BOT 3 + STA,
12
0
II LDA,
BOT
ADC,
BOT
STA,
13
THEN,
DEY,
0=
14
END,
NEXT JMP,
15 -->
FORTH INTERE ST GROUP
MAY 1,
19 7 9
SCR
0
I
2
3
4
5
6
1
8
9
10
I1
I2
13
II 24
(
U/,
UNSIGNED DIVIDE FOR 31 BITS
WFR-79A PR29 )
CODE U/
( 3I BIT DIVIDEN D-2, -3,
I6 BIT DIVISOR -I
*)
( 16 BIT REMAIND ER-2,
16 BIT QUOTIEN T-I
*)
SEC 2 +LOA,
SEC
LOY,
SEC 2 +STY,
.A ASL,
SEC
STA,
SEC 3 +LOA,
SEC 1+ LOY,
SEC 3 +STY,
.A ROL,
SEC 1+ STA,
10 II LDA,
N STA,
BEGIN,
SEC 2 + ROL,
SEC 3 + ROL,
SEC,
SEC 2 + LOA,
BOT
SBC,
TAY,
SEC 3 + LDA,
BOT I+ SBC,
CS IF,
SEC 2+ STY,
SEC 3 + STA,
THEN,
SEC ROL,
SEC I+ ROL,
N DEC,
0=
END,
POP JMP,
-->
I4
IS
SCR II 25
0 (
LOGICALS
1
2 CODE AND
3
BOT
LDA,
4
BOT 1+ LOA,
5
6 CODE OR
7
BOT
LDA,
8
BOT 1+ LDA,
9
10 CODE XOR
1I
BOT
LDA,
I2
BOT 1+ LDA,
I3
14 -->
15
WFR-79A PR20 )
( LOGICAL BITWISE AND OF BOTTOM TWO ITEMS *)
SEC
AND,
PHA,
SEC I+ AND,
INX,
INX,
PUT JMP,
( LOGICAL BITWISE 'OR' OF BOTTOM TWO ITEMS *)
SEC
ORA,
PHA,
SEC I + ORA,
INX,
INX,
PUT JMP,
( LOGICAL 'EXCLUS IVE-OR' OF BOTTOM TWO ITEMS *)
SEC
EOR,
PHA,
SEC 1+ EOR,
INX,
INX,
PUT JMP,
SCR II 2 6
0 (
STACK INITIALI ZATION
WFR-79HA R30 )
1 CODE SP@
. ( FETCH STACK POINTER TO STACK *)
2
TXA,
3 LABEL PUSHOA · PHA,
0 II LDA,
PUSH JMP,
4
5 CODE SP!
6
06 II LDY,
7
8 CODE RP!
9
XSAVE STX,
10
TAX,
08 II LDY,
XSAVE LDX,
UP )Y LDA,
NEXT JMP,
I 1
12 CODE ;S
13
PLA,
14
IS -->
( LOAD SP FROM 'SO' *)
UP )Y LDA,
IP STA,
FORTH INTEREST GROUP
NEXT JMP,
TAX,
( LOAD RP FROM RO *)
TXS,
( RESTORE IP REGISTER FROM RETURN STACK *)
PLA,
IP I+ STA,
NEXT JMP,
MAY 1, 19 7 9
SCR II 27
0 (
RETURN STACK WORDS
WFR-79M AR29 )
1 CODE LEAVE
( FORCE EXIT OF DO-LOOP BY SETTING LIMIT *)
2
XSAVE STX,
TSX,
R LDA,
R 2+ STA,
( TO INDEX *)
3
R 1+ LDA,
R 3 + STA,
XSAVE LDX,
NEXT JMP,
4
5 CODE >R
( MOVE FROM COMP. STACK TO RETURN STACK *)
6
BOT 1+ LDA,
PHA,
BOT LDA,
PHA,
INX,
INX,
NEXT JMP,
7
8 CODE R>
( MOVE FROM RETURN STACK TO COMP. STACK *)
9
DEX,
DEX,
PLA,
BOT STA,
PLA,
BOT 1+ STA,
NEXT JMP,
10
1 1 CODE R
( COPY THE BOTTOM OF RETURN STACK TO COMP. STACK *)
12
XSAVE STX,
TSX,
R LDA,
PHA,
R 1+ LDA,
13
XSAVE LDX,
PUSH JMP,
14 ,
R
-2 BYTE.IN I
15 -->
SCR II 28
0 (
TESTS AND LOGICA LS
WFR-79M AR19 )
1
2 CODE 0=
( REVERSE LOGICAL STATE OF BOTTOM OF STACK *)
3
BOT LDA,
BOT 1+ ORA,
BOT 1+ STY,
4
0= IF,
INY,
THEN,
BOT STY,
NEXT JMP,
5
6 CODE 0<
( LEAVE TRUE IF NEGATI VE; OTHERWISE FALSE *)
7
BOT 1+ ASL,
TYA,
.A ROL,
BOT 1+ STY,
BOT STA,
NEXT JMP,
8
9
10 -->
11
12
13
14
15
SCR
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
WFR-79M AR19 )
( LEAVE THE SUM OF THE BOTTOM TWO STACK ITEMS *)
LDA,
SEC ADC,
SEC STA,
BOT 1+ LDA,
SEC 1+ ADC,
1+ STA,
INX,
INX,
NEXT JMP,
( ADD TWO DOUBLE INTEGE RS, LEAVING DOUBLE *)
2 + LDA ,
B0 T 6 + AD C ,
B0 T 6 + S T A,
3 + LDA,
BOT 7 + ADC,
BOT 7 + STA,
LDA,
BOT 4 + ADC,
BOT 4 + STA,
1 + LDA,
BOT 5 + ADC,
BOT 5 + STA,
POPTWO JMP,
CODE MINUS
( TWOS COMPLEMENT OF BOTTOM SINGLE NUMBER *)
SEC,
TYA,
BOT
SBC,
BOT
STA,
TYA,
BOT 1+ SBC,
BOT 1+ STA,
NEXT JMP,
CODE DMINUS
( TWOS COMPLEMENT OF BOTTOM DOUBLE NUMBER *)
SEC,
TYA,
BOT 2 + SBC,
BOT 2 + STA,
TYA,
BOT 3 + SBC,
BOT 3 + STA,
1 BYTE.IN MINUS
JMP,
-->
FORTH INTERE ST GROUP
MAY 1, 1 9 7 9
SCR II 30
0 (
STACK MANIPULATION
WFR-79HAR 29 )
1 CODE OVER
( DUPLICATE SECOND ITEM AS NEW BOTTOH *)
SEC LDA,
2
PHA,
SEC 1+ LDA,
PUSH JMP,
3
4 CODE DROP
POP
-2
5
BYTE.IN
DROP
6
!
( DROP BOTTOM STACK ITEM *)
( C.F. VECTORS DIRECTLY TO 'POP' )
7 CODE SWAP
( EXCHANGE BOTTOM AND SECOND ITEMS ON STACK *)
8
SEC LDA,
PHA,
BOT LDA,
SEC STA,
9
SEC 1+ LDA,
BOT 1+ LDY,
SEC 1+ STY,
PUT JMP,
10
1 1 CODE DUP
12
BOT LDA,
13
14 -->
15
PHA,
( DUPLICATE BOTTOM ITEM ON STACK *)
BOT 1+ LDA,
PUSH JMP,
SCR II 31
0 ( MEMORY INCREMENT ,
1
2 CODE +!
( ADD
3
CLC,
BOT X)
4
BOT INC,
0=
5
BOT X) LDA,
6
SECOND TO MEMORY 16 BITS ADDRESSED BY BOTTOM *)
L DA ,
S E C AD C ,
B0 T X ) S T A ,
IF,
BOT 1+ INC,
THEN,
SEC 1+ ADC,
BOT X) STA,
POPTWO JMP,
7 CODE TOGGLE
8
SEC X) LDA,
9
WFR-79MAR 30 )
( BYTE AT ADDRESS-2 , BIT PATTERN-I
BOT EOR,
SEC X) STA,
POPTWO JMP,
••• *)
10 -->
11
12
13
14
15
SCR II 3 2
0 (
MEMORY FETCH AND STORE
WFR-78120 2 )
1 CODE @
( REPLACE STACK ADDRESS WITH 16 BIT *)
2
BOT X) LDA,
PHA,
( CONTENTS OF THAT ADDRESS *)
3
BOT INC,
0= IF, BOT 1+ INC,
THEN,
BOT X) LDA,
PUT JMP,
4
5 CODE C@
( REPLACE STACK ADDRESS WITH POINTED 8 BIT BYTE *)
6
BOT X) LDA,
BOT STA,
BOT 1+ STY,
NEXT JMP,
7.
8 CODE !
( STORE SECOND AT 16 BITS ADDRESSED BY BOTTOM *)
SEC LDA,
BOT X) STA,
BOT INC,
0= IF,
BOT 1+ INC,
THEN,
10
SEC 1+ LDA,
BOT X) STA,
POPTWO JMP,
11
12 CODE C!
( STORE SECOND AT BYTE ADDRESSED BY BOTTOM *)
13
SEC LDA,
BOT X) STA, · POPTWO JMP,
14
15 DECIMAL
;S
9
FORTH INTEREST GROUP
MAY 1 ,
19 7 9
SCR
II
0
1
2
3
4
5
6
(
33
•'
.' '
WFR-79MAR30 )
(CREATE NEW COLON-DEFINITION UNTIL ' ; ' *)
?EXEC !CSP CURRENT
@
CONTEXT
CREATE J
; CODE
IMMED lATE
IP 1+ LDA, PHA, IP LDA, PHA, CLC, W LDA,
2 II ADC,
IP STA, TYA, W 1+ ADC, IP 1+ STA, NEXT JMP,
7
8
9
10
11
?CSP
SMUDGE
( TERMINATE COLON-DEFINITION
COMPILE
;S
{
;
IMMEDIATE
*)
12
13
14
15 -->
SCR II 34
0 ( CONSTANT, VARIABLE, USER
WFR-79MAR30 )
1
CONSTANT
( WORD WHICH LATER tREATES CONSTANTS *)
2
CREATE SMUDGE
;CODE
3
Z, II LDY,
W )Y LDA, PHA, INY, W )Y LDA, PUSH JMP,
4
5
VARIABLE
( WORD WHICH LATER CREATES VARIABLES *)
6
CONSTANT ;CODE
7
CLC, W LDA,
2 II ADC, PHA, TYA, W 1+ ADC, PUSH JMP,
8
9
10
11
12
13
14
USER
( CREATE USER VARIABLE *)
CONSTANT ;CODE
2 II LDY, CLC, W ) Y LDA, UP ADC, PHA,
0 # LDA,
UP 1+ ADC, PUSH JMP,
15 -->
SCR II 35
0 ( DEFINED CONSTANTS
1 HEX
2 00
CONSTANT 0
3 02
CONSTANT 2
4 20
CONSTANT BL
5 40
CONSTANT C/L
6
7 3BEO
8 4000
80
9
10
8
CONSTANT
CONSTANT
CONSTANT
CONSTANT
01
03
FIRST
LIMIT
B/BUF
B/SCR
11
12
13 : +ORIGIN
14 -->
WFR-78MAR22 )
00 +ORIGIN
LITERAL +
CONSTANT
CONSTANT
1
3
{ ASCII BLANK *)
( TEXT CHARACTERS PER LINE *)
{ FIRST BYTE RESERVED FOR BUFFERS
( JUST BEYOND TOP OF RAM
( BYTES PER DISC BUFFER
{ BLOCKS PER SCREEN = 1024 B/BUF /
( LEAVES ADDRESS RELATIVE TO ORIGIN *)
15
FORTH INTEREST GROUP
*)
*)
*)
*)
MAY 1 , 19 7 9
SCR II 36
0 (
USER VARIABLES
WFR-78APR29 )
I HEX
( 0 THRU 5 RESERVED,
REFERENCED TO $00AO *)
2 ( 06 USER so )
( TOP OF EMPTY COMPUTATION STACK *)
3 ( 08 USER
RO )
( TOP OF EMPTY RETURN STACK *)
4 OA
USER TIB
( TERMINAL INPUT BUFFER *)
5 oc
USER WIDTH
( MAXIMUM NAME FIELD WIDTH *)
6 OE
USER WARNING
( CONTROL WARNING MODES *)
7 IO
USER FENCE
( BARRIER FOR FORGETTING *)
8 12
USER DP
( DICTIONARY POINTER *)
9 I4
USER VOC-LINK
( TO NEWEST VOCABULARY *)
IO 16
USER BLK
( INTERPRETATICN BLOCK *)
I I 18
USER IN
( OFFSET INTO SOURCE TEXT *)
I2 1A
USER OUT
( DISPLAY CURSOR POSITION *)
I3 lC
USER SCR
( EDITING SCREEN *)
14 -->
I5
SCR
0
1
2
3
4
5
6
7
8
9
II 37
( USER VARIABLES, CONT.
WFR-79APR29 )
IE
USER OFFSET
( POSSIBLY TO OTHER DRIVES *)
20
USER CONTEXT
( VOCABULARY FIRST SEARCHED *)
22
USER CURRENT
( SEARCHED SECOND, COMPILED INTO *)
24_ USER STATE
( COMPILATION STATE *)
26
USER BASE
( FOR NUMERIC INPUT-OUTPUT *)
28
USER DPL
( DECIMAL POINT LOCATION *)
2A
USER FLD
( OUTPUT FIELD WIDTH *)
2C
USER CSP
( CHECK STACK POSITION *)
2E
USER R#
( EDITING CURSOR POSITION *)
30
USER HLD
( POINTS TO LAST CHARACTER HELD IN PAD *)
10
11 -->
12
~3
14
15
SCR II 38
0 ( HI-LEVEL MISC.
WFR-79APR29 )
( INCREMENT STACK NUMBER BY ONE *)
( INCREMENT STACK NUMBER BY TWO *)
3
HERE
DP @
( FETCH NEXT FREE ADDRESS IN DICT. *)
4
ALLOT
DP +!
( MOVE DICT. POINTER AHEAD *)
5
,
HERE
2 ALLOT
. ( ENTER STACK NUMBER TO DICT. *)
6
C,
HERE C!
1
ALLOT
( ENTER STACK BYTE TO DICT. *)
7
MINUS +
( LEAVE DIFF. SEC - BOTTOM *)
8 : =
0=
( LEAVE BOOLEAN OF EQUALITY *)
9 : <
0<
( LEAVE BOOLEAN OF SEC < BOT *)
10
>
SWAP < ;
( LEAVE BOOLEAN OF SEC > BOT *)
11
ROT
>R SWAP R> SWAP
;
( ROTATE THIRD TO BOTTOM *)
I2: SPACE
BL EMIT ;
( PRINT BLANK ON TERMINAL *)
I3 : -DUP
DUP IF DUP END IF
( DUPLICATE NON-ZERO *)
'
14 -->
I
2
1+
2+
1
2
+
+
.
15
FORTH INTEREST GROUP
MAY 1, 19 7 9
SCR II 39
VARIABLE LENGTH NAME SUPPORT
0 (
WFR-79MAR30 )
1
TRAVERSE
( MOVE ACROSS NAME FIELD *)
2
( ADDRESS -2, DIRECTI ON-I, I.E. -l•R TO L, +l=L TO R *)
3
SWAP
4
BEGIN OVER + 7F OVER C@ < UNTIL SWAP DROP
5
6
LATEST
CURRENT
7
@ @
( NFA OF LATEST WORD *)
8
9 ( FOLLOWING HAVE LITERALS DEPENDENT ON COMPUTER WORD SIZE )
10
11
12
13
14
15
LFA
CFA
NFA
PFA
4
2
(
(
(
(
.
t
-1
TRAVERSE
TRAVERSE · 5 +
5
1
CONVERT
CONVERT
CONVERT
CONVERT
A
A
A
A
WORDS
WORDS
WORDS
WORDS
-->
PFA
PFA
PFA
NFA
TO
TO
TO
TO
LFA
CFA
NFA
PFA
*)
*)
*}
*}
SCR II 40
0 (
ERROR PROCEEDURES, PER SHIRA
WFR-79MAR23 )
!CSP
1
SP@ CSP
( SAVE STACK POSITION~IN 'CSP' *)
2
3 .• ?ERROR
( BOOLEAN-2,
ERROR TYPE-I,
4
· SWAP IF
ERROR
ELSE DROP
5
6
?COMP
STATE @ 0= 11 ? ERROR
( ERROR IF
7
8
?EXEC
STATE @ 12 ?ERROR
( ERROR IF
.'
9
10
11
?PAIRS
12
?CSP
13
SP@
?ERROR
CSP @ -
14
?LOADING
BLK
SCR II 41
0 ( COMPILE,
1
2
3
@ 0=
14
SMUDGE,
COMPILE
?COMP
R>
4
5
6
7
8
[
9
SMUDGE
0
co
?ERROR
HEX
DECIMAL
14 -->
?ERROR
HEX, DECIMAL
IMMEDIATE
STATE
LATEST
NOT EXECUTING *)
*)
( VERIFY STACK POSITION *)
( VERIFY LOADING FROM DISC *)
•->
WFR-79APR20 )
( COMPILE THE EXECUTION ADDRESS FOLLOWING
DUP 2+ >R @
STATE
10
11
. 12
13
16
NOT COMPILING *)
( VERIFY STACK VALUES ARE PAIRED
13
15
WARN FOR TRUE *)
END IF
*)
( STOP COMPILATION *)
( ENTER COMPILATION STATE *)
20
TOGGLE
( ALTER LATEST WORD NAME *)
10
BASE
( MAKE HEX THE IN-OUT BASE *)
OA
BASE
( MAKE DECIMAL THE IN-OUT BASE *)
15
FORTH INTEREST GROUP
MAY 1, 1979
SCR fl 4 2
0 (
;CODE
1
2
3
4
5
6
(;CODE)
R>
;CODE
?CSP
7
8
WFR-79APR 20 )
(WRITE CODE FIELD POINTING TO CALLING ADDRESS *)
LATEST
pFA
CFA
,,
COMPILE
[COM~ILE]
(;CODE)
SMUDGE
( TERMINATE A NEW DEFINING WORD *)
IMMEDIATE
9 -->
10
11
12
13
14
15
SCR tl 4 3
0 (
<BUILD,
1
2
<BUILDS
3
DOES>
4
5
DOES>
0
CONSTANT
WFR-79MAR 20 )
( CREATE HEADER FOR 'DOES>' WORD *)
( REWRITE PFA WITH CALLING HI-LEVEL ADDRESS *)
( REWRITE CFA WITH 'DOES>' CODE *)
R>
LATEST
PFA
;CODE .
IP 1+ LDA,
PHA,
IP LDA,
PHA,
( BEGIN FORTH NESTING )
2 # LDY,
W )Y LDA,
IP STA,
( FETCH FIRST PARAM )
INY,
W ) Y LDA,
IP 1+ STA,
( AS NEXT INTERP. PTR )
CLC,
W LDA,
4 fl ADC,
PHA,
( PUSH ADDRESS OF PARAMS )
W 1+ LDA,
00 # ADC,
PUSH JMP,
6
7
8
9
10
11
12
13 -->
14
15
SCR I! 44
0 (
TEXT OUTPUTS
WFR-79APR 02 )
1
COUNT
DUP 1+ SWAP C@
( LEAVE TEXT ADDR. CHAR. COUNT *)
TYPE
2
( TYPE STRING FROM ADDRESS-2 , CHAR.COUN T-1 *)
3
-DUP
IF OVER + SWAP
4
DO I C@ EMIT LOOP
ELSE DROP ENDIF
5
-TRAILING
( ADJUST CHAR. COUNT TO DROP TRAILING BLANKS *)
6
DUP
0 DO
OVER OVER
+ 1
C@
7
BL
IF
LEAVE
ELS$
1
ENDIF
LOOP
( • II)
8
( TYPE IN-LINE STRING, ADJUSTING RETURN *)
9
R COUNT DUP
1+ R>
+ >R TYPE
10
11
12
13
14
15
.
.
II
IF
22
STATE @
COMPILE
(. 11 )
ELSE
WORD
IMMEDIATE
FORTH INTEREST GROUP
( COMPILE OR PRINT QUOTED STRING *)
WORD
HERE
C@
1+ ALLOT
HERE
COUNT
TYPE
ENDIF
-->
MAY 1 ,
19 7 9
SCR t! 4 5
TERMINAL INPUT
0 (
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
WFR-79APR29_)
EXPECT
( TERMINAL INPUT MEMORY-2, CHAR LIMIT-I *)
OVER + OVER DO KEY DUP OE +ORIGIN ( BS ) @ =
IF DROP 08 OVER I = DUP R> 2
+ >R
ELSE ( NOT BS ) DUP OD =
IF ( RET ) LEAVE DROP BL 0 ELSE DUP END IF
I
C! 0 I
1+
ENDIF EMIT LOOP DROP
QUERY
TIB @ 50 EXPECT 0 IN
8081 HERE
: X
BLK @
( END-OF-TEXT IS NULL *)
IF ( DISC ) 1 BL K +!
0 IN ! BLK @ 7 AND 0=
IF ( SCR END ) ?EXEC R> DROP ENDIF
ELSE ( TERMINAL )
R> DROP
END IF
IMMEDIATE
-->
SCR II 46
0 (· FILL, ERASE, BLANKS, HOLD, PAD
1
FILL
( FILL MEMORY BEGIN-3 ,
2
SWAP >R OVER C! DUP 1+ R> 1
3
4
5
6
ERASE
7
BLANKS
0
8
FILL
BL
FILL
-1
HLD
( FILL MEMORY WITH ZEROS
;
WFR-79APR02 )
QUAN-2, BYTE-I
*)
\
CMOVE ;
BEGIN-2 ,
QUAN-1 *)
( FILL WITH BLANKS BEGIN-2 , QUAN-1 *)
9
10
HOLD
11
12
13
PAD
14
15. -->
..
+!
HLD
@
C!
( HOLD CHARACTER IN PAD *)
.
(
HERE 44 +
( PAD IS 68 BYTES ABOVE HERE *)
'
DOWNWARD HAS NUMERIC
OUTPUTS; UPWARD-MAY HOLD TEXT *)
SCR II 47
0 (
WORD,
WFR-79APR02 )
1
WORD
( ENTER WITH DELIMITER, MOVE STRING TO 'HERE' *)
BLK @ IF BLK @
2
BLOCK
ELSE TIB @ ENDIF
3
IN @ + SWAP
( ADDRESS-2, DELIMIT ER-I )
4
ENCLOSE
( ADDRESS-4, START-3 , END-2, TOTAL COUNT-1 )
5
HERE 22 BLANKS
( PREPARE FIELD OF 34 BLANKS )
6
IN +!
( STEP OVER THIS STRING )
OVER
7
>R
( SAVE CHAR COUNT )
8
R HERE C!
( LENGTH STORED FIRST )
+ HERE 1+
9
10
R> CMOVE
( MOVE STRING FROM BUFFER TO HERE+! )
'
.
11
12
13
14
15 -->
FORTH INTEREST GROUP
- MAY 1, 19 7 9
SCR II 48
0 (
(NUMBER-,
NUMBER,
-FIND,
WFR-79APR 29 )
1
(NUMBER)
( CONVERT DOUBLE NUMBER, LEAVING UNCONV. ADDR. *)
2
BEGIN
1+ DUP
>R
C@
BASE
@ DIGIT
3
SWAP
WHILE
BASE
@ U*
DROP
ROT
BASE
@ U*
D+
4
DPL
@ 1+
IF
1 DPL +!
ENDIF
R>
REPEAT
R>
5
6
NUMBER
( ENTER W/ STRING ADDR.
LEAVE DOUBLE NUMBER *)
7
0
0
ROT
DUP
1+ C@
2D
DUP
>R
+ -1
8
BEGIN DPL
(NUMBER)
DUP
C@
BL
9
WHILE
DUP
C@
2E
0
?ERROR
0 REPEAT
10
DROP
R>
IF
DMINUS
ENDIF
11
12
-FIND
( RETURN PFA-3, LEN BYTE-2, TRUE-1; ELSE FALSE *)
13
BL
WORD
HERE
CONTEXT
@ @ (FIND)
14
DUP
0=
IF
DROP
HERE
LATEST
(FIND)
ENDIF
15 -->
SCR
II
0
1
2
3
4
5
(
6
7
8
9
10
49
ERROR HANDLER
(ABORT)
WFR-79APR 20 )
ABORT
( USER ALTERABLE ERROR ABORT *)
ERROR
( WARNING:
-1=ABORT, O=NO DISC, 1=DISC *)
WARNING
@ 0<
( PRINT TEXT LINE REL TO SCR //4 *)
IF
(ABORT)
ENDIF
HERE
COUNT
TYPE
"
? "
MESSAGE
IN
SP!
@ BLK
@
QUIT
ID.
11
12 -->
13
14
15
PAD
PAD
( PRINT NAME FIELD FROM ITS HEADER ADDRESS *)
020
SF
FILL DUP
PFA LFA OVER
SWAP
CMOVE
PAD
COUNT
OlF AND
TYPE
SPACE
SCR II 50
0 (
CREATE
WFR-79APR 28 )
1
2
CREATE
( A SMUDGED CODE HEADER TO PARAM FIELD *)
3
( WARNING IF DUPLICATIN G A CURRENT NAME_*)
TIB
4
HERE
OAO +
< 2
?ERROR
( FREE SPACE ? )
5
-FIND
( CHECK IF UNIQUE IN CURRENT AND CONTEXT )
IF ( WARN USER )
6
DROP
NFA
ID.
7
4
MESSAGE
SPACE
ENDIF
8
HERE
DUP
C@
WIDTH
@
MIN
1+ ALLOT
DP
9
C@
OFD
=
ALLOT
10
DUP
AO
TOGGLE
HERE
1
80 TOGGLE ( DELIMIT BITS )
11
LATEST
CURRENT
@
12
HERE
2+
13 -->
14
15
FORTH INTEREST GROUP
MAY 1, 1 9 7 9
SCR If 51
0 ( LITERA L,
DLITERAL,
[COMPI LE],
1
2
3
(COMPILE]
-FIND
0=
6
7
LITERAL
STATE
@ IF
COMPILE
8
9
DLITERAL
STATE
@ IF
SWAP
WFR-79APR29 )
( FORCE COMPILATION OF AN IM~EDIATE WORD *)
?ERROR DROP CFA
IMMEDIATE
0
4
5
?STACK
( IF COMPILING, CREATE LITERAL *)
LIT
ENDIF
IMMEDIATE
( IF COMPILING, CREATE DOUBLE LITERAL *)
(COMPILE]
LITERAL
[COMPILE]
LITERAL ENDIF ; IMMEDIATE
10
11
12 (
FOLLOWING DEFINIT ION IS INSTALLATION DEPENDENT )
13
?STACK
( QUESTION UPON OVER OR UNDERFLOW OF STACK *)
14
15 -->
09E
SP@
<
1
?ERROR
SCR If 52
0 (
INTERP RET,
2
4
5
020
<
7
?ERROR
WFR-79APR18 )
1
3
SP@
INTERPRET
BEGIN
IF
( INTERPRET OR COMPILE SOURCE TEXT INPUT WORDS *)
-FIND
( FOUND ) STATE @ <
IF CFA ,
ELSE CFA EXECUTE ENDIF ?STACK
ELSE HERE NUMBER DPL @ 1+
IF
(COMPILE]
DLITERAL
ELSE
DROP
(COMPILE]
LITERAL ENDIF ?STACK
ENDIF AGAIN
6
7
8
9
10 -->
11
12
13
14
15
SCR If 53
0 (
IMMEDIATE,
VOCAB, DEFIN,
FORTH,
(
DJK-WF R-79APR 29 )
1
IMMEDIATE
( TOGGLE PREC. BIT OF LATEST CURRENT WORD *)
2
LATEST 40 TOGGLE
3
4
5
6
7
8
VOCABULARY
( CREATE VOCAB WITH 'V-HEA D' AT VOC INTERS ECT. *)
<BUILDS A081
CURRENT @ CFA
HERE VOC-LINK @
VOC-LINK
DOES> 2+ CONTEXT
9 VOCABULARY
FORTH
10
11
DEFINIT IONS
12
CONTEXT @
13
14
15
(
29
WORD
FORTH INTEREST GROUP
IMMEDIATE
( THE TRUNK VOCABULARY *)
( SET THE CONTEXT ALSO AS CURRENT VOCAB *}
CURRENT
( SKIP INPUT TEXT UNTIL RIGHT PARENTHESIS *)
IMMEDIATE
-->
MAY 1 , 1 9 7 9
L/1
SCR II 54
0 (
QUIT,
ABORT
WFR-79MAR30 )
1
2
3
4
5
6
7
8
9
10
11
QUIT
( RESTART,
INTERPRET FROM TERMINAL *)
0 BLK
[COMPILE}
[
BEGIN RP!
CR QUERY
INTERPRET
STATE @ 0= IF
" OK" ENDIF AGAIN
ABORT
( WARM RESTART, INCLUDING REGISTERS *)
SP!
DECIMAL
DRO
CR ." FORTH-65 V 4.0"
[CONPILEJ
FORTH DEFIN ITIONS QUIT
12
13 -->
14
15
SCR II 55
0 ( COLD START
WFR-79APR29 )
1 CODE COLD
( COLD START, INITIA LIZING USER AREA *)
2
HERE 02 +ORIG IN
( POINT COLD ENTRY TO HERE )
3
OC +ORIG IN LDA,
'T FORTH 4 + STA,
( FORTH VOCAB. )
4
OD +ORIG IN LDA,
'T FORTH 5 + STA,
5
15 If LDY, ( INDEX TO VOC-LINK ) 0= IF, ( FORCED )
6
HERE 06 +ORIG IN !
( POINT RE-ENTRY TO HERE )
7
OF II LDY,
( INDEX TO WARNING )
THEN, ( FROM IF, )
8
10 +ORIG IN LDA,
UP
STA,
( LOAD UP )
9
11 +ORIG IN LDA,
UP 1+ STA,
10
BEGIN ,
OC +ORIG IN , Y LDA,
( FROM LITERAL AREA )
11
UP )Y STA,
(TO USER AREA)
12
DEY,
0< END,
13
'T ABORT 100 /MOD II LDA,
IP 1+ STA,
14
If LDA,
IP
STA,
15
6C II LDA,
W 1 - STA,
'T RP! JMP, ( RUN ) -->
SCR II 56
0 ( MATH UTILIT Y
1 CODE S->D
2
BOT 1+ LDA,
3
4
5
6
+-
DJK-W FR-79A PR29 )
( EXTEND SINGLE INTEGER TO DOUBLE *)
0< IF, DEY, THEN,
TYA, PHA, PUSH JMP,
0< IF MINUS ENDIF
D+-
7
0<
IF
DMINUS
8
9
10
11
12
13
14
15
ABS
DABS
DUP
DUP
( APPLY SIGN TO DOUBLE NUMBER BENEATH *)
ENDIF
+D+-
LEAVE SMALLER OF TWO NUHBERS
END IF DROP
( LEAVE LARGET OF TWO NUMBERS
SWAP END IF DROP
-->
(
OVER
OVER
>
IF
OVER
OVER
<
IF
FORTH INTEREST GROUP
( LEAVE ABSOLUTE VALUE
DOUBLE INTEGER ABSOLUTE VALUE
(
MIN
MAX
( APPLY SIGN TO NUMBER BENEATH *)
SWAP
MAY 1 '
1979
*)
*)
*)
*)
SCR II 57
0 ( HATH PACKAGE
DJK-W FR-79A PR29 )
I
M*
( LEAVE SIGNED DOUBLE PRODUCT OF TWO SINGLE NUMBERS *)
2
OVER OVER XOR >R ABS SWAP ABS U* R> D+;
3
H/
( FROM SIGNED D0UBL E-3-2, SIGNED DIVISO R-I *)
4
( LEAVE SIGNED REMAINDER-2, SIGNED QUOTIENT-I *)
5
OVER >R >R DABS R ABS U/
6
R> R XOR +- SWAP R> +- SWAP
,
U* DROP
7 : *
( SIGNED PRODUCT *)
8
/MOD
>R S->D R> M/
( LEAVE REM-2 , QUOT-1 *)
9
/MOD
I
SWAP DROP
( LEAVE QUOTIENT *).
I0
MOD
/HOD DROP
(
LEAVE REMAINDER *)
'( TAKE RATION OF
11
*/MOD
THREE NUMBERS, LEAVING *)
12
>R
M* R> M/
( REM-2 , QUOTI ENT-I *)
I3
*/MOD
SWAP DROP
*I
( LEAVE RATIO OF THREE NUMBS *)
14
M/MOD
( DOUBLE, SINGLE DIVISO R ••• REMAINDER, DOUB LE*)
15
>R 0 R u I
SWAP >R U/ R>
R>
~->
.
SCR II 58
0 ( DISC UTILIT Y,
GENERAL USE
WFR-79APR02 )
1 FIRST
VARIABLE USE
( NEXT BUFFER TO USE, STALEST *)
2 FIRST VARIABLE PREV
( MOST RECENTLY REFERENCED BUFFER *)
3
4
5
6
7
8
9
10
11
I2
13
14
15
+BUF
( ADVANCE ADDRESS-I TO NEXT BUFFER. RETURNS FALSE *)
84 ( I.E. B/BUF +4 ) + DUP LIMIT =
( IF AT PREV *)
IF DROP FIRST ENDIF DUP PREV @
UPDATE
PREV
( MARK THE BUFFER POINTED TO BY PREV AS ALTERED *)
@ @ 8000 OR PREV
@
EMPTY-BUFFERS
( CLEAR BLOCK BUFFERS; DON'T WRITE TO DISC *)
FIRST LIMIT OVER
ERASE
DRO
DRl
0
07DO
OFFSET
OFFSET
-->
( SELECT DRIVE #0 *)
( SELECT DRIVE #I *)
SCR II 59
0 ( BUFFER
WFR-79APR02 )
I
BUFFER
( CONVERT BLOCK/I TO STORAGE ADDRESS *)
2
USE @ DUP >R
( BUFFER ADDRESS TO BE ASSIGNED )
3
BEGIN +BUF UNTIL ( AVOID PREV ) USE
( FOR NEXT TIME )
4
R @ 0<
( TEST FOR UPDATE IN THIS BUFFER )
5
IF ( UPDATED, FLUSH TO DISC )
6
R
2+ ( STORAGE LOC. )
7
R
@
7FFF AND
( ITS BLOCK II )
8
0
R/W
( WRITE SECTOR TO DISC )
9
END IF
10
R
( WRITE NEW BLOCK # INTO THIS BUFFER )
11
R
PREV
( ASSIGN THIS BUFFER AS 'PREV ' )
12
R>
2+
( MOVE TO STORAGE LOCATION )
13
14 -->
15
FORTH INTEREST GROUP
MAY 1 , 1 9 7 9
SCR II 60
0 (
BLOCK
WFR-79APR02 )
1 :. BLOCK
( CONVERT BLOCK NUMBER TO ITS BUFFER ADDRESS *)
OFFSET @ + >R
2
( RETAIN BLOCK # ON RETURN STACK )
PREV @ OUP @ R
3
DUP + ( BL 0 CK = P·R EV ? )
4
IF ( NOT PREV )
5
BEGIN +BUF 0=
( TRUE UPON REACHING 'PREV' )
6
IF ( WRAPPED ) DROP R BUFFER
7
DUP R 1
R/W
( READ SECTOR FROM DISC )
8
2 - ( BACKUP )
9
END IF
10
DUP @ R
DUP + 0=
11
UN T I L ( WI TH BUF F ER ADD RES S )
12
DUP PREV
13
END IF
14
R> DROP
2+
15 -->
SCR II 61
0 ( TEXT OUTPUT FORMATTING
WFR-79MAY03 )
1
2
3
4
(LINE)
( LINE/!, SCR/1, •••
>R C/L B/BUF */MOD R>
BLOCK + C/L
.LINE
( LINE#,
SCR#,
(LINE)
-TRAILIN G
BUFFER ADDRESS, 64 COUNT *)
B/SCR * +
5
6
7
TYPE
PRINTED *)
8
9
10
11
12
13
MESSAGE
( PRINT LINE RELATIVE TO SCREEN #4 OF DRIVE 0 *)
WARNING @
IF
( DISC IS AVAILABLE )
-DUP IF 4 OFFSET @ B/SCR /
.LINE ENDIF
ELSE
II
MSG # "
END IF
14 -->
15
SCR II 62
0 ( LOAD,
-->
WFR-79APR02 )
1
2
3
4
LOAD
BLK @ >R IN @
INTERPRET R> IN
>R
0
R>
( INTERPRET SCREENS FROM DISC *)
IN
B/SCR * BLK
BLK
5
6
7
-->
8
9
?LOADING 0
MOD
BLK
IN
+!
( CONTINUE INTERPRETATION ON NEXT SCREEN *)
B/SCR BLK @ OVER
IMMEDIATE
10 -->
11
12
13
14
15
FORTH INTEREST GROUP
HAY 1, 19 7 9
SCR II 63
0 (
INSTALLAT ION DEPENDENT TERMINAL I-0,
TIM
WFR-79APR 26
1 ( EMIT )
ASSEMBLER
2
HERE
BYTE. IN
-2
EMIT
( VECTOR EMITS' CF TO HERE )
XSAVE STX,
3
BOT LDA,
7F II AND, 72C6 JSR,
XSAVE LDX,
4
CLC,
1 A II LDY,
UP )Y LDA,
01 II ADC,
UP )Y STA,
5
INY,
UP )Y LDA,
00 II ADC,
UP )Y STA,
POP JMP,
6
( AND INCREMENT 'OUT' )
7 ( KEY
HERE
8
-2
BYTE.IN
KEY
( VECTOR KEYS' CF TO HERE )
9
XSAVE STX,
BEGIN,
8 # LDX,
10
BEGIN,
6E02 LOA,
.A LSR,
CS END,
7320 JSR,
11
BEGIN,
7310 JSR,
0 X) CMP,
0 X) CMP,
0 X) CMP,
12
0 X) CMP,
0 X) CMP,
6E02 LDA,
.A LSR,
PHP,
TYA,
13
.A LSR,
PLP,
CS IF,
80 # ORA,
THEN,
TAY,
DEX,
14
0= END,
7310 JSR,
FF II EOR,
7F II AND,
0= NOT END,
15
XSAVE LDX,
PUSHOA JMP,
-->
SCR II 6 4
0 (
INSTALLAT ION DEPENDENT TERMINAL I-0,
TIM
WFR-79APR 02 )
1
2 ( ?TERMINAL )
3
HERE
BYTE. IN
-2
?TERMINAL
( VECTOR LIKEWISE )
4
1 II LDA, 6E02 BIT, 0= NOT
IF,
5
BEGIN,
731D JSR,
6E02 BIT,
0= END,
INY,
THEN,
6
TYA,
PUSHOA JMP,
7
8 ( CR )
9
HERE
BYTE.IN
-2
CR
( VECTOR CRS' CF TO HERE )
10
XSAVE STX,
728A JSR,
XSAVE LDX, NEXT JMP,
11
1 2 -->
13
14
15
SCR II 65
0 (
INSTALLAT ION DEPENDENT DISC
1 6900
CONSTANT DATA
2 690l
CONSTANT
STATUS
3
WFR-79APR 02 )
( CONTROLLER PC>RT lc ).
( CONTROLLER PORT *)
4
5
IIHL
6
0
OA
U/
( CONVERT DECIMAL DIGIT FOR DISC CONTROLLER *)
SWAP
30 + HOLD
7
8 -->
9
10
11
12
13
14
15
FORTH INTEREST GROUP
MAY 1,
19 7 9
SCR II 66
0 (
D/CHAR,
?DISC,
WFR-79MAR23
I CODED/C HAR
(TEST CHAR-I. EXIT TEST BOOL-2, NEW CHAR-I *)
2
DEX,
DEX,
BOT 1+ STY,
CO I LDA,
3
BEGIN,
STATUS BIT,
0= NOT END,
( TILL CONTROL READY )
4
DATA LDA,
BOT STA,
( SAVE CHAR )
5
SEC CMP,
0= IF,
!NY,
THEN,
SEC STY,
NEXT JMP,
6
7
8
9
I0
11
12
I3
14
15
?DISC
( UPON NAK SHOW ERR MSG, QUIT.
ABSORBS TILL *)
I
D/CHAR
>R 0=
( EDT, EXCEPT FOR SOH *)
IF
( NOT SOH )
R I5 =
IF ( NAK )
CR
BEGIN 4 D/CHAR EMIT
UNTIL ( PRINT ERR MSG TIL EDT )
QUIT
ENDIF
( FOR ENQ, ACK )
BEGIN 4 D/CHAR DROP UNTIL
( AT EDT )
ENDIF R> DROP
;
-->
SCR II 67
0 ( BLOCK-WRITE
WFR-790 103 )
1 CODE BLOCK-WRITE
( SEND TO DISC FROM ADDRESS -2,
COUNT-I *)
2
2 II LDA,
SETUP JSR,
( WITH EOT AT END *)
3
BEGIN,
02 II LDA,
4
BEGIN,
STATUS BIT,
0• END,
( TILL IDLE )
5
N CPY, 0•
6
IF, ( DONE )
04 II LDA,
STATUS STA,
DATA STA,
7
NEXT JMP,
8
THEN,
9
N 2+ ) Y LDA,
DATA STA,
INY,
10
0•
END,
( FORCED TO BEGIN )
11
12 -->
13
14
15
SCR II 6 8
0 (
BLOCK-READ,
WFR-790 103 )
1
2 CODE BLOCK-READ
( BUF.ADD R-1. EXIT AT 128 CHAR OR CONTROL *).
1 # LDA,
3
SETUP JSR,
4
BEGIN,
CO # LDA,
5
BEGIN,
STATUS BIT,
0= NOT END,
( TILL FLAG )
6
50 ( BVC, D6=DATA )
7
8
9
10
11
12 -->
13
14
I5
IF,
DATA LDA,
N )Y STA,
!NY,
SWAP
0< END,
( LOOP TILL I28 BYTES )
THEN,
( OR D6=0, SO D7a1, )
NEXT JMP,
FORTH INTEREST GROUP
MAY 1, 19 7 9
SCR II 69
0 (
R/W
FOR PERSCI 1070 CONTROLLER
WFR-79MAY 03 )
1 OA
ALLOT
HERE
( WORKSPACE TO PREPARE DISC CONTROL TEXT )
2
( IN FORM:
C TT SS /D,
TT=TRACK, SS=SECTOR , D=DRIVE )
3
( C = I TO READ, 0 TO WRITE *)
4
R/W
( READ/WRIT E DISC BLOCK *)
5
( BUFFER ADDRESS-3 , BLOCK #-2, 1=READ O=WRITE *)
6
LITERAL
HLD
! ( JUST AFTER WORKSPACE )
SWAP
7
0
OVER
>
OVER
OF9F
> OR
6
?ERROR
8
0700
( 2000 SECT/DR )
/MOD
IIHL
DROP
2F
HOLD
BL
HOLD
9
1A
/MOD
SWAP 1+ #HL
#HL
DROP
BL
HOLD
( SECTOR 01-26 )
10
#HL
#HL
DROP
BL
HOLD
( TRACK
00-76 )
11
DUP
'IF
49 ( I=READ)
12
ELSE 4F ( O=WRITE )
ENDIF
13
HOLD
HLD
@ OA BLOCK-WRI TE
( SEND TEXT ) ?DISC
IF
14
BLOCK-READ
ELSE
B/BUF
BLOCK-WRI TE
ENDIF
15
?DISC
-->
SCR II 70
0 { FORWARD REFERENCE S
1 00
BYTE. IN
2 02
BYTE. IN
3 04
BYTE. IN
4 08
BYTE.IN
5 oc
BYTE. IN
6 OE
BYTE. IN
7 10
BYTE. IN
8 00 BYTE. IN
9 02
BYTE. IN
10 06
BYTE. IN
11 08
BYTE. IN
'
12 00
BYTE. IN
CONSTANT
1 3 0 2 BYTE. IN
CONSTANT
14 04
BYTE.IN
CONSTANT
15 06
BYTE.IN
CONSTANT
.
SCR
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
II 71
(
FORWARD REFERENCE S
02
BYTE.IN
VARIABLE
02
BYTE.IN USER
06
BYTE.IN
?ERROR
OF
BYTE.IN
II
1D
BYTE.IN
II
00
BYTE.IN
(ABORT)
19
BYTE.IN
ERROR
25
BYTE.IN ERROR
oc BYTE.IN WORD
lE BYTE. IN CREATE
2C
BYTE. IN
CREATE
BYTE.IN ABORT
04
2C
BYTE. IN
BUFFER
BYTE. IN
30
BLOCK
FORTH INTEREST GROUP
WFR-79HAR 30 )
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED. BY
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED. BY
REPLACED.B Y
REPLACED. BY
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED.B Y
REPLACED. BY
REPLACED.B Y
?EXEC
!CSP
CURRENT
CONTEXT
CREATE
J
(;CODE)
?CSP
COMPILE
SMUDGE
[
CREATE
SMUDGE
'(;CODE)
-->
WFR-79APR 29
(;CODE)
(;CODE)
ERROR
WORD
WORD
ABORT
MESSAGE
QUIT
BLOCK
HESSAGE
MIN
DRO
R/W
R/W
DECIMAL
MAY 1 ,
;S
19 7 9
)
SCR II 7 2
0 (
1 HEX
2
3
1
4
5
6
7
8
9
10
FORGET,
\
WFR-79APR28 )
3
WIDTH
( FIND NEXT WORDS PFA; COMPILE IT, IF COMPILING *)
-FIND 0= 0 ?ERROR DROP
[COMPILE]
LITERAL
;
IMMEDIATE
FORGET
( FOLLOWING WORD FROM CURRENT VOCABULARY *)
CURRENT @ CONTEXT @
18 ?ERROR
,
[COMPILE]
DUP FENCE @ < 15 ?ERROR
DUP NFA DP
LFA @ CURRENT @
11
12
13 -->
14
15
SCR II 73
0 ( CONDITIONAL COMPILER, PER SHIRA
WFR-79APR01 )
1
BACK
HERE
( RESOLVE BACKWARD BRANCH *)
2
3
4
5
6
7
8
9
10
11
12
13
BEGIN
?COMP
END IF
?COMP 2 ?PAIRS
THEN
(COMPILE]
DO
COMPILE
LOOP
3
?PAIRS
COMPILE
(LOOP)
+LOOP
3
?PAIRS
COMPILE
(+LOOP)
BACK
UNTIL
1
?PAIRS
COMPILE
OBRANCH
BACK
HERE
1
IMMEDIATE
HERE
END IF
(DO)
HERE
14
15
SCR If 74
0 ( CONDITIONAL COMPILER
END
1
[COMPILE]
UNTIL
2
3
4
5
6
7
8
9
10
OVER
SWAP
IMMEDIATE
IMMEDIATE
3
BACK
?PAIRS
BRANCH
BACK
REPEAT
>R
>R
[COMPILE]
AGAIN
R> R>
2
[COMPILE]
ENDIF
COMPILE
ELSE
2
?PAIRS COMPILE
SWAP
2
[COMPILE]
11
12
13 : WHILE
[COMPILE]
14
15 -->
FORTH INTEREST GROUP
OBRANCH
IF
2+
IMMEDIATE
IMMEDIATE
-->
WFR-79APR01 )
1
IF
IMMEDIATE
IMMEDIATE
AGAIN
COMPILE
IMMEDIATE
HERE
0
IMMEDIATE
IMHEDIATE
IMMEDIATE
2
BRANCH HERE
ENDIF 2
0
IMMEDIATE
IMMEDIATE
MAY 1, 19 7 9
SCR II 75
0 ( NUMERIC PRIMIT IVES
1
SPACES
0 MAX -DUP
2
3
<II
PAD
II>
DROP
SIGN
ROT
0<
BASE
@
IF
0
DO
SPACE
LOOP
WFR-79APR01
ENDIF
HLD
4
5
DROP
HLD
PAD
@
6
7
8
9
10
11
12
II
.
II s
BEGIN
13 -->
IF
2D
HOLD
OVER
END IF
( CONVERT ONE DIGIT , HOLDING IN PAD
M/MOD ROT 9 OVER < IF
7 + ENDIF 30 + HOLD *
II
OVER
OVER
OR
0=
)
UNTIL
14
15
SCR II 76
0 (
OUTPUT OPERATORS
WFR-79APR20 )
1
D.R
( DOUBLE INTEGER OUTPUT, RIGHT ALIGNED IN FIELD *)
2
>R SWAP OVER DABS <# #S SIGN #>
3
R> OVER
SPACES TYPE
4
5
6
D.
0
7
.R
>R
8
9 :
•
S->D
?
@
10
11
12
13 ,
CFA
D.R
SPACE
S->D
R>
( DOUBLE INTEGER OUTPUT *)
D.R
( ALIGNED SINGLE INTEGER *)
D.
( SINGLE INTEGER OUTPUT *)
( PRINT CONTENTS OF MEMORY *)
,
14 -->
15
MESSAGE
2A
+
( PRINT MESSAGE NUMBER ) .
SCR II 7 7
0 (
PROGRAM DOCUMENTATION
WFR-79APR20 )
1 HEX
2 : LIST
( LIST SCREEN BY NUMBER ON STACK *)
3
DECIMAL
CR DUP SCR
II
SCR # II
4
10 0 DO CR I
3 .R SPACE
5
I
SCR @ .LINE LOOP CR
6
7
8
9
INDEX
10
11
12
13
14
15
TRIAD
( PRINT FIRST LINE OF EACH SCREEN FROM2,
T0-1 *)
EMIT ( FORM FEED )
CR
1+ SWAP
DO CR I
3
.R SPACE
0 I
.LINE
?TERMINAL IF LEAVE END IF LOOP
;
( PRINT 3 SCREENS ON PAGE, CONTAINING II ON STACK *)
oc EMIT ( FF ) 3 I 3 * 3 OVER + SWAP
DO CR I LIST LOOP CR
OF MESSAGE CR
DECIMAL
-->
oc
FORTH INTEREST GROUP
MAY 1 , 19 7 9
'·~
SCR II 78
0 ( TOOLS
1 HEX
2
VLIST
WFR-79APR20 )
80
3
4
5
BEGIN
6
7 -->
8
OUT
DUP
DUP
( LIST CONTEXT VOCABULARY *)
OUT
CONTEXT @ @
@ C/L > IF CR 0 OUT
ENDIF
ID.
SPACE SPACE
PFA LFA @
0= ?TERMINAL OR UNTIL DROP
9
10
11
12
13
14
15
SCR II 79
0 ( TOOLS
1 HEX
WFR-79MAY03 )
2
3 CREATE
4
5
6
MON
0 C,
( CALL MONITOR, SAVING RE-ENTRY TO FORTH *)
4C C,
' LIT 18 + ,
SMUDGE
7
8
9
10
11
12
13
14
15
DECIMAL
HERE
HERE
HERE
LATEST
'
FORTH
28
30
12
6
FENCE
+ORIGIN
( COLD START FENCE }
+ORIGIN
( COLD $TART DP )
+ORIGIN
( TOPMOST WORD )
+ 32 +ORIGIN
( COLD VOC-LINK )
;S
SCR II 80
0 -->
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
FORTH INTEREST GROUP
MAY 1, 19 79
This is a sample editor, compatable with the fig-FORTH model and simple terminal
devices. The Iine and screen editing functions are portable. The code definition
for the string MATCH could be written
high level or translated
SCR fl 87
0 ( TEXT, LINE
WFR-79MAY01 )
1 FORTH DEFINITIONS
HEX
2
TEXT
( ACCEPT FOLLOWING ~EXT TO PAD *)
3
HERE C/L 1+
BLANKS WORD HERE PAD C/L 1+ CMOVE
Q
4
5
6
LINE
DUP
SCR
7
FFFO AND
@
(LINE)
8 -->
( RELATIVE TO SCR, LEAVE ADDRESS OF LINE *)
17 ?ERROR
( KEEP ON THIS SCREEN )
DROP
9
10
11
12
13
I4
15
SCR II 8 8
0 (
LINE EDITOR
WFR-79MAY03 )
1 VOCABULARY
EDITOR IMMEDIATE
HEX
2
WHERE
( PRINT SCREEN # AND IMAGE OF ERROR *)
3
DUP B/SCR / DUP SCR
." SCR # " DECIMAL
4
SWAP C/L /MOD C/L * ROT BLOCK + CR C/L TYPE
5
CR HERE C@
SPACES SE EMIT
[COMPILE] EDITOR QUIT
6
7 EDITOR
DEFINITI ONS
/!LOCATE
( LEAVE CURSOR OFFSET- 2, LINE-1 *}
Rll
@ C/L
/MOD
II LEAD
( LINE ADDRESS-2, OFFSET- ! TO CURSOR *)
IILOCATE LINE
SWAP
;
I! LAG
( CURSOR ADDRESS-2, COUNT-I AFTER CURSOR *)
IILEAD DUP >R + C/L R>
;
-MOVE
( MOVE IN BLOCK BUFFER ADDR FROM-2, LINE T0-1 *)
LINE C/L CMOVE UPDATE · ;
-->
8
9
10
11
12
13
14
15
SCR II 89
0 (
LINE EDITING COMMANDS
1
H
2
LINE PAD 1+ C/L
.
DUP
3
4
E
LINE
5
6
7
8
s
9
10
11
C/L
DUP 1
DO I LINE
BLANKS
LIMIT
1+
I
DUP H OF DUP
DO I
1+ LINE
13
( ERASE LINE-1 WITH BLANKS *)
UPDATE
(
(
D
12
14
15
WFR-79MAY03 )
( HOLD NUMBERED LINE AT PAD *)
PAD C! CMOVE
)
OE
-MOVE
(
SPREAD MAKING LINE II BLANK *)
FIRST TO MOVE )
-1 +LOOP E
( DELETE LINE-I, BUT HOLD IN PAD *)
ROT
I -MOVE LOOP E
-->
FORTH INTEREST GROUP
MAY 1, 19 7 9 ·
...$/
SCR II 90
0 (
LINE EDITING COMMANDS
1
2
3
4
5
M
(
MOVE CURSOR BY SIGNED AMOUNT-I, PRINT ITS LINE *)
+!
CR SPACE II LEAD TYPE SF EUIT
II LAG
TYPE
//LOCATE
DROP
(
TYPE LINE BY Il-l ,
SAVE ALSO IN PAD *)
C/L * Rll
DUP H 0 M
Rfl
T
6
7
DUP
8
9 : L
10
11 -->
WFR-79MAY03
)
( RE-LIST SCREEN *)
SCR @ LIST 0 M
12
13
14
15
SCR II 91
0 (
LINE EDITING COMMANDS
I
2
3
4
5
6
7
8
9
I0
I I
R
PAD
I+
SWAP
-MOVE
WFR-79 0105 )
( REPLACE ON LINE 11-1, FROM PAD *)
p
I
TEXT
I
s
DUP
.
R
TOP
0
( PUT FOLLOWING TEXT ON LINE-1 *)
R
Rfl
( INSERT TEXT FROM PAD ONTO LINE II *)
CR
( HOME CURSOR TO TOP LEFt OF SCREEN *)
12 -->
I3
14
15
SCR II 92
0 ( SCREEN EDITING COMMANDS
1
CLEAR
2
SCR
10 0 DO FORTH
3
4
5
6
7
8
9
10
II
I
WFR-79APR27 )
( CLEAR SCREEN BY NUMBER-I *)
EDITOR E LOOP
FLUSH
( WRITE ALL UPDATED BLOCKS TO DISC *)
[ LIMIT FIRST
B /BUF 4 + /
]
( NUMBER OF BUFFERS)
LITERAL 0 DO 7FFF BUFFER DROP LOOP
COPY
B/SCR * OFFSET
DO DUP FORTH I
DROP FLUSH
( DUPLICATE SCREEN -2, ONTO SCREEN-I *)
@ + SWAP B/SCR * B/SCR OVER + SWAP
BLOCK 2
1+
UPDATE LOOP
12 -->
13
14
15
FORTH INTEREST GROUP
MAY 1 , 19 7 9
SCR II 93
STRING EDITING PRIMITIVES
0 (
WFR~79APR21 )
( CURSOR ADDRESS-4, BYTES LEFT-3, STRING ADDR-2 *)
1 CODE MATCH
2
( ITS COUNT-I. LEAVE BOOLEAN-2, CURSOR ADVANCEMEN~-1 *)
4 II LDA, SETUP JSR, DEX, DEX, DEX, DEX,
3
BOT STY, BOT 1+ STY,
4
BEG IN,
( NEW HATCH ) DROP
5
( ERR ) FF II LDY,
BEG IN, DROP ( ERR ) INY, N CPY, CS NOT
6
IF, ( Y < STRING ) N 2+ )Y LDA, N 6 + )Y CMP,
7
0• NOT UNTIL,
8 ROT 1
( REPEAT FOR GOOD MATCH )
N 6 + INC,
9
0= IF,
N 7 + INC, ENDIF,
BOT
10
INC,
0= IF,
BOT 1+ INC, END IF, ( CUR MOT )
11
N 4 + LDA,
0= IF,
N 5 + DEC, ENDIF,
12
N 4 + DEC,·
( DECREMENT BUFFER REMAINING )
13
N 4 + LDA, N CMP,
( REMAINING - STRING SIZE )
14
N 5 + LDA, N 1+ SBC,
1 5 ROT 1
CS NOT UNTIL,
-->
( REPT TILL OUT OF BUFFER )
SCR II 94
0 {
1
2
3
4
5
6
CONCLUSION OF STRING MATCH
WFR-79APR22 )
0 II LDA,
SEC STA, SEC 1+ STA,
{ BOOLEAN FALSE )
N 4 + LDY,
( SPACE UNTIL END OF BUFFER )
ENDIF,
CLC, TYA, BOT ADC, PHA,
0 II LDA,
BOT 1+ ADC,
( ADJUST CURSOR MOTION )
PUT JMP,
C;
7 -->
8
9
10
11
12
13
14
15
SCR II 95
0 (
STRING EDITING COMMANDS
WFR-79MAR24 )
1
!LINE
{ SCAN LINE WITH CURSOR FOR MATCH TO PAD TEXT, *)
2
{ UPDATE CURSOR, RETURN BOOLEAN *)
3
IILAG PAD COUNT MATCH Rll +!
4
5
6
7
FIND
{ STRING AT PAD OVER FULL SCREEN RANGE, ELSE ERROR *)
BEGIN 3FF R# @ <
IF TOP PAD HERE C/L 1+ CMOVE 0 ERROR END IF
!LINE
UNTIL
8
9
10
DELETE
11
>R IILAG + FORTH R
12
#LAG R MINUS R# +1
13
#LEAD + SWAP CMOVE
14
R> BLANKS UPDATE
15 -->
FORTH INTEREST GROUP
{ BACKWARDS AT CURSOR BY COUNT-I *)
( SAVE BLANK FILL LOCATION )
( BACKUP CURSOR )
( FILL FROM END OF TEXT )
MAY 1, 19 7 9
SCR II 96
WFR-79MAR24 )
STRING EDITOR COMMANDS
0 (
*)
T&XT
( FIND NEXT OCCURANCE OF PREVIOUS
N
1
FIND 0 M ;
2
3
( FIND OCCURANCE OF FOLLOWING TEXT *)
4
F
N
1 TEXT
5
6
( BACKUP CURSOR BY TEXT IN PAD *)
7 : B
C@ MINUS M
PAD
8
9
( DELETE FOLLOWING TEXT *)
X
10
C@ DELETE 0 M
PAD
FIND
1 TEXT
11
12
( DELETE ON CURSOR LINE, FROM CURSOR TO TEXT END *)
TILL
13
0 ?ERROR
!LINE 0•
1 · TEXT
#LEAD +
14
-->
DELETE 0 M
#LEAD + SWAP
15
r'
SCR II 97
WFR-79MAR23 )
0 ( STRING EDITOR COMMANDS
( SPREAD AT CURSOR AND COPY IN THE FOLLOWING TEXT *)
C
1
PAD COUNT
1 TEXT
2
>R
#LAG ROT OVER MIN
3
{ BUMP CURSOR )
FORTH R Ril +!
4
( CHARS TO SAVE )
>R
R
5
( FROM OLD CURSOR TO HERE )
CMOVE
R
HERE
DUP
6
( HERE TO CURSOR LOCATION )
CMOVE
R>
+
/ILEAD
HERE
7
OLD CURSOR )
TO
PAD
(
UPDATE
R> CMOVE
8
)
LINE
0 M ( LOOK AT NEW
9
DECIMAL
DEFINITIONS
10 FORTH
(TOP NFA)
12 +ORIGIN
11 LATEST
( FENCE )
28 +ORIGIN
12 HERE
DP )
(
30 +ORIGIN
13 HERE
( VOC-LINK )
32 +ORIGIN
EDITOR 6 +
14
;S
15 HERE FENCE
{
I
SCR # 98
0
1
2
3
4
5
6
7
8
9
10
11
....
·
"
12
13
14
15
FORTH INTEREST GROUP
u
MAY 1, 19 79
">
/
Télécharger
Juste un petit rappel. Vous pouvez consulter le document ici même. Mais surtout, notre IA l''a déjà lu. Il peut expliquer des choses complexes en termes simples, répondre à vos questions dans n''importe quelle langue et vous aider à naviguer rapidement même dans les documents les plus longs ou les plus compliqués.
Publicité