💾 Archived View for mirrors.apple2.org.za › archive › apple2.archive.umich.edu › apple2 › 8bit › pro… captured on 2024-12-17 at 23:11:17.

View Raw

More Information

-=-=-=-=-=-=-

This is the intro file for QForth. I will be available at tm@polari.UUCP
for about one more week, then I'll have to find another account (I'm moving).
 
 
: newdefs
 
;
 
: title
 
  page
 
  1 cv 30 ch
  ." QForth 2.0 Alpha 1.0 "
 
  3 cv 16 ch
  ." (c) 1988 Toshiyasu Morita, all rights reserved "
 
  5 cv 18 ch
  ." (Type 'read intro' to execute this file) "
 
  8 cv 18 ch
  ." 1) QForth overview "
 
  9 cv 18 ch
  ." 2) QForth conditionals & loop statements "
 
  10 cv 18 ch
  ." 3) QForth stack manipulation statements "
 
  11 cv 18 ch
  ." 4) QForth miscellaneous statements "
 
  12 cv 18 ch
  ." 5) Exit this menu "
 
  15 cv 20 ch
  ." Please select help file to view:  "
 
;
 
: overview
 
  page
 
  1 cv 32 ch
  ." QForth Overview "
 
  3 cv 6 ch
  ." QForth is a fast, integer Forth designed for developing small "
  4 cv 6 ch
  ." applications. QForth currently supports only unsigned integer "
  5 cv 6 ch
  ." arithmetic, making it unsuitable for number-crunching applications. "
 
  7 cv 6 ch
  ." QForth is, however, well-suited for developing small applications "
  8 cv 6 ch
  ." that need to run quickly using little memory. QForth is perfect "
  9 cv 6 ch
  ." for this task, since source compiles directly into machine language "
  10 cv 6 ch
  ." and the kernel (presently) occupies a mere 6k. "
 
  12 cv 6 ch
  ." This package does not include an editor as part of the language, so an "
  13 cv 6 ch
  ." external full-screen editor is suggested. (Applewriter 2.1 is highly "
  14 cv 6 ch
  ." recommended) "
 
  16 cv 6 ch
  ." Since this is an alpha version, bugs and/or crashes are highly likely. "
  17 cv 6 ch
  ." Please keep backups of your source files for safety! "
 
  22 cv 32 ch
  ." Press any key:  "
 
  key drop 0
 
;
 
: conditionals
 
  page
 
  1 cv 22 ch
  ." QForth conditionals & loop operators "
 
  3 cv 6 ch
  ." DO-LOOP: counts from top item in stack to 2nd item on stack. "
  4 cv 6 ch
  ."          loop variable is accessed through i and j. i will push "
  5 cv 6 ch
  ."          the innermost loop counter on the stack, and j will push "
  6 cv 6 ch
  ."          the next-to-innermost loop counter on the stack. "
 
  8 cv 6 ch
  ." DO-+LOOP: Same as DO-LOOP except top item on stack is used at +LOOP "
  9 cv 6 ch
  ."           to increment the loop counter. "
 
  11 cv 6 ch
  ." IF-ELSE-THEN: Basic Forth conditional. Top of stack is evaluated "
  12 cv 6 ch
  ."               at IF. If the value is true then execution continues "
  13 cv 6 ch
  ."               after IF to ELSE, then resumes execution at THEN. "
  14 cv 6 ch
  ."               If value is false then execution continues after ELSE "
  15 cv 6 ch
  ."               and on through THEN. "
 
  17 cv 6 ch
  ." BEGIN-UNTIL: Executes statements between BEGIN and UNTIL, then top "
  18 cv 6 ch
  ."              of stack is evaluated at UNTIL. If value is true then "
  19 cv 6 ch
  ."              then execution exits loop, otherwise it loops to BEGIN. "
 
  22 cv 32 ch
  ." Press any key:  "
 
  key drop
 
  page
 
  1 cv 22 ch
  ." Qforth conditionals & loop operators "
 
  3 cv 6 ch
  ." BEGIN-REPEAT-WHILE: Execution proceeds from BEGIN to REPEAT, then "
  4 cv 6 ch
  ."                     the the top of stack is tested at REPEAT. If top "
  5 cv 6 ch
  ."                     of stack is true, then execution continues to "
  6 cv 6 ch
  ."                     REPEAT and loops back to BEGIN otherwise the loop "
  7 cv 6 ch
  ."                     terminates. "
 
  22 cv 32 ch
  ." Press any key:  "
 
  key drop
 
;
 
: stack
 
  page
 
  1 cv 22 ch
  ." QForth stack manipulation statements "
 
  3 cv 6 ch
  ." +, -, *, /, MOD: Performs specified operation on stack in "
  4 cv 6 ch
  ."                  reverse-polish notation. "
 
  6 cv 6 ch
  ." DUP: Duplicates top item on stack so that there are two copies. "
 
  8 cv 6 ch
  ." DROP: Discards top item on stack. "
 
  10 cv 6 ch
  ." SWAP: Reverses order of top two stack items, e.g. x, y becomes y, x. "
 
  12 cv 6 ch
  ." OVER: Makes a copy of next-to-top stack item and pushes it on stack. "
 
  14 cv 6 ch
  ." ROT: Rotates third item on stack to top, e.g. x, y, z becomes y, z, x. "
 
  16 cv 6 ch
  ." >R: Moves top item on data stack to return stack. "
 
  18 cv 6 ch
  ." R>: Moves top item on return stack to data stack. "
 
  20 cv 6 ch
  ." R@: Copies top return stack item to data stack without removing it. "
 
  22 cv 32 ch
  ." Press any key:  "
 
  key drop
 
  page
 
  1 cv 22 ch
  ." QForth stack manipulation statements "
 
  3 cv 6 ch
  ." .: Prints out top item on stack followed by a space. "
 
  5 cv 6 ch
  ." NOT, AND, OR, XOR, <, >, =: Performs specified operation on stack, "
  6 cv 6 ch
  ."                             leaves result on stack. "
 
  8 cv 6 ch
  ." 1+, 1-, 2+, 2-: Performs equivalent of 1 + or 1 -, etc. except words "
  9 cv 6 ch
  ."                 are optimized for speed. "
 
  11 cv 6 ch
  ." 2*, 2/: Arithmetic left shift and right shift, respectively. "
 
  22 cv 32 ch
  ." Press any key:  "
 
  key drop
 
;
 
: other
 
  page
 
  1 cv 28 ch
  ." QForth other statements "
 
  3 cv 6 ch
  ." !, @: Store and fetch two bytes from address to & from stack. "
 
  5 cv 6 ch
  ." C!, C@: Store and fetch single bytes from address to & from stack. "
 
  7 cv 6 ch
  ." PAGE: Clear screen and home cursor. "
 
  9 cv 6 ch
  ." CV: Set cursor vertical position to top value on stack. "
 
  11 cv 6 ch
  ." CH: Set cursor horizontal position to top value on stack. "
 
  13 cv 6 ch
  ." KEY: Wait for a keypress, push ASCII value on stack. (high bit clear) "
 
  15 cv 6 ch
  ." EMIT: Output to screen the ASCII value on stack. (high bit ignored) "
 
  17 cv 6 ch
  ." CR, SPC: Output return and space to screen, respectively. "
 
  19 cv 6 ch
  ." . " 34 emit ." : Output string to screen, must be terminated by another "
  ."  quote. "
 
  22 cv 32 ch
  ." Press any key:  "
 
  key drop
 
;
 
: main
 
  title
 
    begin
 
      key 48 -
 
      dup 1 =
        if
          overview
          title
        else
        then
 
      dup 2 =
        if
          conditionals
          title
        else
        then
 
      dup 3 =
        if
          stack
          title
        else
        then
 
      dup 4 =
        if
          other
          title
        else
        then
 
    5 =
    until
 
    forget newdefs
 
;
 
close main