================================================================
 fig-FORTH-79 Blocks -- filename.FRT or .FOR or .SCR
================================================================

 Preamble
---------
The FORTH high level computer language was developed around 1970
by C. Moore and E. Rather [1]. There were many different
installations available for the Microcomputers in the early
1980s. I made my first aquaintance with an installation by David
Husband [2] on the Sinclair/Timex ZX81, used another one on the
Digital Research CP/M (8080/Z80) and finally ported that
installation to MSDOS 3.2 (8086).

The FORTH language is completely structured and capable of
multitasking. Imagine: a ZX81 and a CP/M microcomputer doing
multitaking.


 The FRT (FOR/SCR) format
--------------------------
The CP/M and early DOS versions of FORTH used fixed format
source files that could be read by the FORTH interpreter and
compiled to a program. The file extension usually was "FRT", but
this was not mandatory. Sometimes, "FOR" was used, but that
could be mixed up with FORTRAN source files and was seldom used.
Another file extension that was sometimes used is "SCR" -- for
screen -- for reasons that may become obvious in a moment.

The source files contained one or more blocks with 1024 bytes
each. A block had 16 lines with 64 ascii characters per line,
the lines being padded by blanks (ascii space). The files were
produced by the Editor and called Screens.

The files had no header - just 1024 bytes or a multiple of it.
The FORTH word "-->" loaded and interpreted the next block.


 Sample FORTH file
-------------------
This example was taken from [3] (SCR # 60 thru 62) and shows
how blocks are loaded and screens displayed. The beauty of FORTH
is the fact that you can write a FORTH interpreter/compiler with
the language itself -- only a few assembler primitives are
needed.

 0        1         2         3         4         5         6
 1234567890123456789012345678901234567890123456789012345678901234
+----------------------------------------------------------------+
(  BLOCK                                           WFR-79APR02 )  1
: BLOCK         ( CONVERT BLOCK NUMBER TO ITS BUFFER ADDRESS * )  2
   OFFSET  @  +  >R     RETAIN BLOCK # ON RETURN STACK )          3
   PREV  @  DUP  @  R  -  DUP  +  ( BLOCK = PREV ? )              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
           ENDIF                                                 10
           DUP  @  R  - DUP  + 0=                                11
        UNTIL  ( WITH BUFFER ADDRESS )                           12
      DUP  PREV  !                                               13
     ENDIF                                                       14
     R>  DROP    2+  ;                                           15
-->                                                              16
+----------------------------------------------------------------+
(  TEXT OUTPUT FORMATTING                          WFR-79MAY03 )  1
                                                                  2
: (LINE)         ( LINE#, SCR#, ... BUFFER ADDRESS, 64 COUNT * )  3
         >R  C/L  B/BUF  */MOD  R>  B/SCR  *  +                   4
         BLOCK  +  C/L  ;                                         5
                                                                  6
: .LINE   ( LINE#,  SCR#, ... PRINTED *)                          7
         (LINE)  -TRAILING  TYPE  ;                               8
                                                                  9
: MESSAGE       ( PRINT LINE RELATIVE TO SCREEN #4 OF DRIVE 0 *) 10
    WARNING  @                                                   11
    IF  ( DISC IS AVAILABLE )                                    12
        -DUP  IF  4  OFFSET  @  B/SCR  /  -  .LINE   ENDIF       13
        ELSE  ." MSG # "          .    ENDIF  ;                  14
-->                                                              15
                                                                 16
+----------------------------------------------------------------+
(  LOAD,  -->                                      WFR-79APR02 )  1
                                                                  2
: LOAD                          ( INTERPRET SCREENS FROM DISC *)  3
    BLK  @  >R  IN  @  >R  0  IN  !  B/SCR  *  BLK  !             4
    INTERPRET  R>  IN  !  R>  BLK  !  ;                           5
                                                                  6
: -->                ( CONTINUE INTERPRETATION ON NEXT SCREEN *)  7
     ?LOADING  0  IN   !  B/SCR  BLK  @  OVER                     8
     MOD  -  BLK  +!   ;    IMMEDIATE                             9
                                                                 10
-->                                                              11
                                                                 12
                                                                 13
                                                                 14
                                                                 15
                                                                 16
+----------------------------------------------------------------+


 REFERENCES
------------
[1] Moore, Charles H.; Rather, Elisabeth D.; The FORTH Program
    for Spectral Line Observing. Proceedings of the IEEE,
    Vol. 61, No. 9, September 1973, pp 1346 - 1349.

[2] Husband, David; Sinclair ZX81-FORTH ROM with Multi-Tasking,
    1983. Skywave Software, Bournemouth, UK.

[3] Ragsdale, William F.; fig-FORTH Installation Manual,
    November 1980. FORTH Interest Group, San Carlos.


 Author
--------
hans-rudolf.wernli@bluewin.ch
http://mypage.bluewin.ch/horo/
05. August 2002
