A Short Program in Forth (ZX Forth)

See all articles from Sinc-Link v1 n2
Author(s): J. J. Castillos
Publication: Sinc-Link
Pub Details: Sinc-Link v1 n2 (Volume 1, Issue 2)
Pages: 3-4

If you are like me, you got your copy of ZX FORTH, loaded it, played a bit with it and after realizing how different it was from BASIC, you put it away for a while. Just now I am beginning to grasp the elementary notions of FORTH programming and I would like to share with you a short program which shows some simple graphic and printing routines (each # represents one blank space). Compare the speed of execution with a similar BASIC program, for example, any of the BASIC games you may have which starts by drawing a black border around the screen.

                                    (30 spaces)
: G 24 1 DO CR ."##" 128 EMIT ."##############################" 128 EMIT LOOP ; Newline

: A ."##" 31 0 DO 128 EMIT LOOP ; Newline

: M 10 1 DO CR LOOP ; Newline

: E ."##" 128 EMIT ."####THIS IS A DEMONSTRATION" CR CR ; Newline

: S ."##" 128 EMIT ."#####OF FORTH GRAPHICS..." CR CR ; Newline

(14 spaces)
: X ."##" 128 EMIT ."##############" ; Newline

After making the above definitions exactly as listed, you can run the program by entering the following list of words:

TASK G A HOME A M E S X  Newline

and see what happens. Remember that after the laborious entering of the definitions, these stay in memory and are added to your Vocabulary, the actual program is the last short line of words.

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