Site Tools


Miscellaneous Projects, Demos, and Tests

OF816 for Apple IIgs

This is a cross-platform Forth interpreter (it also runs on the W65C816SXB, but we won't worry about that for now). It's a ProDOS SYS file but requires an Apple IIgs. It does not need GS/OS to run.

forth-5ce84572.po

Things to Try

$GS-USERID ( – u ) return the Toolbox user ID of the running Forth.

$GS-TOOLCALL ( i*n i t1 j t2 tool# – j*n ) call Toolbox, passing i arguments to the tool, and receiving j results. t1 and t2 are the type bits for the arguments and results, respectively, where b0 = the first arg, b1 the second arg, etc. A 1 bit means the argument or result is a long, 0 indicates a word. Arguments and results are specified/received in reverse order from the toolbox call (topmost on the Forth stack is bottommost on the return stack).

Some pre-canned toolbox calls:

_TOTALMEM ( – u ) return total system memory

_READBPARAM ( u1 – u2 ) read battery RAM parameter u1

_READTIMEHEX ( – u1 u2 u3 u4 ) read time in hex format

_READASCIITIME ( addr – ) read 20 byte time string into adds.

decimal 20 alloc-mem value timebuf
timebuf _readasciitime
timebuf 20 type

_FWENTRY ( addr y x a – y x a p ) call firmware entry in bank 0

ff2d 0 0 0 _fwentry
ERR

_SYSBEEP ( – ) play system bell

_SYSFAILMGR ( addr u – ) call fatal error handler, u = error code, addr = address of packed string message or 0.

Interpreter Info

OF816 is a direct-threaded Forth with 32-bit cells and 8-bit characters.

ANS Forth Conformance

  • Providing the Core word set.
  • Providing .(, .R, 0<>, 0>, 2>R, 2R@, :NONAME, <>, ?DO, AGAIN, CASE, COMPILE,, ENDCASE, ENDOF, ERASE, EXPECT, FALSE, HEX, NIP, PAD, PARSE, PICK, REFILL, RESTORE-INPUT, ROLL, SAVE-INPUT, SOURCE-ID, SPAN, TO, TRUE, TUCK, U.R, U>, UNUSED, VALUE, WITHIN, [COMPILE], and \ from the Core Extensions word set.
  • Providing 2CONSTANT, D+, D-, D.R, D>S, DABS, DNEGATE, and 2ROT from thge Double-Number word set.
  • Providing the Exception word set.
  • Providing the Facility word set.
  • Providing Programming-Tools word set.
  • Providing ;CODE, AHEAD, BYE, CODE, FORGET, and STATE from the Programming-Tools Extensions word set.
  • Providing the Search Order word set.
  • Providing -TRAILING, BLANK, SEARCH, and SLITERAL from the String word set.

Console I/O

At startup, it initializes the slot 3 Pascal I/O interface which, on a IIgs, is always going to be the built in text display. It sets up vectors for the input, output, and status calls. These calls are the only thing that happen in emulation mode after Forth is initialized.

The platform-independent portion of the code expects the output to accept ANSI sequences, and PAGE and AT-XY output them. OF816 for the Apple IIgs' console driver translates some ANSI sequences for cursor position and erasing to equivalents recognized by the video firmware.

Data Space

The data space is acquired from the Toolbox and is currently set at 32K and is allowed to cross bank boundaries.

Updated SmartWatch Utility

Includes tests and ability to disable the oscillator. SmartWatch Utility v. MG 2.0a