home *** CD-ROM | disk | FTP | other *** search
-
- \ This file is filled with more example commands for you
- \ to try out.
- \
- \ Type them in, as displayed, and observe the results.
- \ After some commands is a short description of the
- \ action the command performs. (Remember, JForth is
- \ NOT case-sensitive, so the text may be entered in
- \ either upper- or lower-case.)
- \
- \ NOTE: some of the following include command SEQUENCES.
- \ This means that those lines which do not have at least
- \ one blank line between then need to be typed in
- \ in order. (Remember, text after '\' characters or
- \ between a single parentheses and its 'mate' are
- \ comments and need not be typed in, like this text.
- \
- \ TIME-SAVERS...
- \
- \ Don't forget that the F1 key will save you the trouble of having
- \ to type in INCLUDE each time. Also, remember that SHIFT-UP-ARROW
- \ is how to use JForth's COMMAND LINE HISTORY to recall a previous
- \ line to the screen for another entry with or without editing.
- \
- \ NOTE: It IS possible to INCLUDE this file, but for purposes of
- \ learning, it is much better to follow through the commands
- \ by hand.
-
-
-
- \ In the programs directory is the source for an IFF picture viewer
- \ using JForth's IFF support files. These command compile it, then
- \ display a lo-res IFF picture we've put in the Tutorials directory.
-
- INCLUDE PROGRAMS/SHOW_IFF
- JSHOW TUTORIALS/STORM.IFF
- \ Click in the top-left corner of the picture to close it.
- \ When you're done experimenting with LINES, enter:
- FORGET TASK-SHOW_IFF
-
-
-
- : ADD3 16 32 + 64 + . ;
- ADD3
- DEF ADD3
-
- \ The above compiles a word which adds 3 numbers and prints the answer.
- \ It then executes the word.
- \ The 3rd line displays the code the compiler put together.
-
-
-
- FORGET ADD3
- DEBUG{
- : ADD3 16 32 + 64 + . ;
- }DEBUG
- DEBUG ADD3
- \ then press the SPACE BAR repeatedly, until the Debugger window goes away.
-
- \ The above compiled ADD3 again, this time with DEBUG turned on.
- \ The last line executed ADD3, using the 'single-step' function of
- \ the Debugger.
- \ The user then presses the SPACE BAR to single-step the program. Note
- \ the data stack manipulations are displayed with each action.
- \ Note that pressing the '?' key will display a list of debugger commands
- \ (while inside the debugger) and that any key will pause the list, then
- \ any key will continue.
-
-
-
- TYPEFILE S:STARTUP-SEQUENCE
-
- \ Pause with SPACE-BAR, then RETURN to continue. Many JForth display
- \ words pause like this... provided by the word ?PAUSE. For example...
-
- : JUSTHELLO
- 100 0
- DO
- ." HELLO" ?PAUSE CR
- LOOP
- ;
- JUSTHELLO
-
- \ Before the above word finishes, hit the SPACE-BAR and the stream
- \ of HELLOs will stop. Hit RETURN to continue. Enter JUSTHELLO again
- \ if it finishes before you have a chance to try the PAUSE feature.
-
-
-
- INCLUDE PROGRAMS/QUARTERS.F
- 8239 QUARTERS
- \ When you're done experimenting with Quarters, enter:
- FORGET TASK-QUARTERS.F
-
-
-
- INCLUDE PROGRAMS/DEMO_LINES
- LINES
- \ This demo runs until you click the lines windows closebox.
- \ When you're done experimenting with LINES, enter:
- FORGET TASK-DEMO_LINES
-
-
-
- \ Interactive graphics example...
-
- GR.INIT
- GR.OPENTEST
- 20 20 GR.MOVE
- 80 20 GR.DRAW
- 20 30 GR.MOVE
- " HERE IS SOME TEXT" GR.TEXT
- 40 40 120 60 GR.RECT
- GR.CLOSECURW
-
-
- \ That's about if for the example commands, unless you're interested
- \ in JForth's assembler interface. If so, continue...
-
- \ Assembly examples
-
- ASM PUSH.5.ON.STACK ( -- 5 )
- MOVE.L D7,-(A6) \ push current top-of-stack out
- MOVEQ.L #5,D7 \ put a '5' in the top-of-stack register
- END-CODE
-
- \ The above word illustrates JForth's "cached data stack"...
- \ The topmost "item on the stack" is really kept in data reg 7,
- \ and the memory for the "rest of the stack" is pointed to by
- \ addr reg 6.
-
- \ JForth allows these registers to be specified with names more
- \ descriptive of these functions. Data reg 7 can be called TOS
- \ and addr reg 6's other name is DSP (for Data Stack Pointer)
- \ So the following word is identical to the previous one.
-
- ASM PUSH.ANOTHER.5 ( -- 5 )
- MOVE.L TOS,-(DSP) \ push current top-of-stack out
- MOVEQ.L #5,TOS \ put a '5' in the top-of-stack register
- END-CODE
-
- \ NOTE: You can tell the disassembler to display either standard
- \ Motorola register names, or JForth's custom names, by setting
- \ a variable called DISM-NAMES. Entering: DISM-NAMES OFF
- \ will tell the disassembler to use standard names, DISM-NAMES ON
- \ will cause the custom names to appear.
-
- \ NOTE: All assembly words have to start with ASM and the name
- \ of the function, and end with the single statement END-CODE in
- \ the first column.
-
- \ The following assembly word illustrates some common
- \ assembly operations such as:
- \
- \ 1. defining and branching to a local label
- \ 2. Interactively referencing JForth words (like constant values)
- \ 3. CALLing other high-level words.
-
- ASM EXAMPLE.CODE ( n -- n*2 , just a bunch of example code, double 'n' )
- ASL.L TOS \ do the 'real work and double the passed in parameter
- \
- \ the rest is just example. First let's DUP the answer then
- \ print its value (with .HEX)
- \
- CALLCFA DUP \ we'll see what the compiler puts together later
- CALLCFA .HEX \ by using DEF
- \
- \ zero the value if it is negative or equal to MEMF_CHIP
- \
- TST.L TOS
- BPL 2$
- 1$: MOVEQ.L #0,TOS
- BRA 3$
- 2$: CMP.L #[MEMF_CHIP],TOS
- BEQ 1$
- 3$: RTS
- \
- \ That's it!
- \
- END-CODE
-
- 6 EXAMPLE.CODE . ( should print double )
- DEF EXAMPLE.CODE
-