2068 fig-Forth

An implementation of Z80 fig-Forth 1.1d for the TS2068 by E. A. Worden (loader: “Version 2.31, 9-29-84”). It includes a standard editor for screens of 16 lines by 64 characters, and a few nonstandard words, such as TAPE-SAVE, SCR-SAVE, SCR-LOAD and BYE (which returns one to BASIC). Other additions in the dictionary include BEEP, DEPTH, NLIST, STATUS, .CPU, TRIAD and INDEX. The full fig-Forth word set is there, including <BUILDS … DOES>, vocabularies, FORGET and the block buffer words.

When it starts, the loader asks for COLD, WARM or BASIC. The second code block, FORTH-SCR, holds a set of Forth screens: the system’s error messages and two “DISPLAY” screens that POKE in a machine code patch with small hex-loading words.

Program Analysis

Tape Contents

  • Forth Load: the BASIC program (auto-run at line 1), which loads the Forth code and stays in memory to serve it.
  • Forth: the Forth system, 16,512 bytes at 36864.
  • FORTH-SCR: 11,339 bytes of screens at 53376, loaded by SCR-LOAD.

How Forth and BASIC Work Together

Forth runs as machine code entered with RANDOMIZE USR 36918, but returns to BASIC whenever it needs input or output. Lines 1405–1415 look at the two bytes at 37000/37001 to see why Forth stopped, and BASIC then prints a character (and copies it to the printer if the flag at 37107 is set), reads a key, handles carriage return, or saves and loads the system and screens, before calling Forth again.

Notable Techniques

  • Lines 1550–1567 give Forth access to BASIC’s graphics, colour, sound and maths: PLOT, DRAW, COPY, CLS, BORDER, INK, PAPER, FLASH, BRIGHT, BEEP, and SIN, COS, TAN, ASN, ACS, ATN and LN. Numbers for the maths functions are passed as text through a buffer at 36833 and turned into numbers with VAL and back with STR$.
  • Keys are decoded with GO TO 7000+CODE m$, so each key code has its own line. The keyword keys reached with SYMBOL SHIFT (AT, OR, AND, THEN, TO, STEP) are mapped to characters Forth needs, such as [ ] { } \, and two CAPS-shifted number keys (codes 4 and 7) turn caps lock on and off.
  • Forth’s own save words come back to BASIC lines 9000–9130, which save and verify the system or the screens to tape.

Related Products

Implementation of Z80 fig-Forth 1.1d on the TS 2068.

Related Articles

It’s good to that Forths for the 2068 are beginning to appear, and as might be expected Hawg Wild (aka Gary Smith) is first to send us one for review.

Image Gallery

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.