FLASH186 Forth Primer ********************* FLASH186 is a version of F-PC ported to run on Flashlite186, a DOS based single board computer. FLASH186 is a full Forth which contains a Multitasker, Debugger, Decompiler, and a 80186 Assembler. It also supports vocabularies and is capable of making auto-start applications. This is all available in just 85 Kbytes of space. RUNNING FLASH186 **************** Upload FLASH186.EXE to the Flashlite board and execute it. After the HELLO screen, hit enter to get the "ok" prompt. We are now in FORTH and can execute words directly. FLASH186 boots up with the FORTH vocabulary selected. To view all the words in this vocabulary type --> WORDS. Lets test-drive FLASH186 a bit and see how we can exercise a few functions on the FlashLite board. Type in the following commands at the "ok" prompt: LED.ON ----> Will turn on LED. (FlashLite on-board LED DS1) LED.OFF ----> Will turn off LED. BLINK.LED ----> Will blink the LED. (Hit any key to stop) BEEP ----> Will beep the speaker. .TIME ----> Will show the current time. .DATE ----> Will show the current date. To create a time delay: 5 SECONDS ----> Wait 5 seconds for the "ok" prompt. 2 MINUTES ----> Wait 2 minutes for the "ok" prompt. 2 HOURS ----> Wait 2 hours. ( Don't try this now!) There is one I/O pin available directly off the R8822 Micro. To configure it as an output ----> PIO1.OUTPUT To turn it on ----> PIO1.ON To turn it off ----> PIO1.OFF To configure it as an input ----> PIO1.INPUT To read the bit value ----> PIO1.ON? ----> PIO1.OFF? With the words available in the FORTH vocabulary we can work all I/O ports down to bit level. Here are some examples to work PORTA. The same techniques can be used for the other ports. I/O ports A to F are available on the Flashlite board. These I/O are controlled by a CPLD that operates on 3.3 volts. Ports A & B are are 4 bit ports and C thru F are 8 bit ports. PORTA ***** PORTA.INPUT ----> Configure Port A as inputs PORTA.OUTPUT ----> Configure Port A as outputs PA.0 HIGH ----> Force PA.0 I/O line HIGH PA.1 LOW ----> Force PA.1 I/O line LOW PA.2 TOGGLE ----> Toggle PA.2 I/O line PA.3 ON? ----> Is PA.3 HIGH ? PORTB ***** PORTB.INPUT ----> Configure Port B as inputs PORTB.OUTPUT ----> Configure Port B as outputs ( HIGH/LOW can be replaced by >ON/>OFF ) PB.0 >ON ----> Force PB.0 I/O line ON PB.1 >OFF ----> Force PB.1 I/O line OFF PB.2 TOGGLE ----> Toggle PB.2 I/O line PB.3 OFF? ----> IS PB.3 LOW ? PORTC ***** PORTC.INPUT ----> Configure Port C as inputs PORTC.OUTPUT ----> Configure Port C as outputs PC.0 HIGH ----> Force PC.0 HIGH PC.1 LOW ----> Force PC.1 LOW PC.2 TOGGLE ----> Toggle PC.2 PC.3 PC.4 ON? ----> Is PC.4 HIGH ? PC.5 OFF? ----> IS PC.5 LOW ? PC.6 PC.7 PORTD ***** PORTD.INPUT ----> Configure Port D as inputs PORTD.OUTPUT ----> Configure Port D as outputs PD.0 HIGH PD.1 LOW PD.2 TOGGLE PD.3 PD.4 ON? PD.5 OFF? PD.6 PD.7 PORTE ***** PORTE.INPUT ----> Configure Port E as inputs PORTE.OUTPUT ----> Configure Port E as outputs PE.0 HIGH PE.1 LOW PE.2 TOGGLE PE.3 PE.4 ON? PE.5 OFF? PE.6 PE.7 PORTF ***** PORTF.INPUT ----> Configure Port F as inputs PORTF.OUTPUT ----> Configure Port F as outputs PE.0 HIGH PE.1 LOW PE.2 TOGGLE PE.3 PE.4 ON? PE.5 OFF? PE.6 PE.7 To Read or Write to the I/O ports in BYTE format: PORTC READ ----> Read PORTC status ( byte value ) $EF PORTB WRITE ----> Write byte $EF to PORTC Lets try some sequential programming: LED.ON 2 SECONDS LED.OFF The onboard LED will turn ON for 2 seconds then turn OFF. LED.ON 2 SECONDS LED.OFF 1 SECONDS 3 TIMES The LED will turn ON for 2 seconds then turn OFF for 1 second. This will be repeated 3 times. Lets speed things up a bit: LED.ON 200 MS LED.OFF 200 MS 10 TIMES The LED will turn ON for 200 milliseconds then OFF for 200 ms This will be repeated 10 times. LED.ON 200 MS LED.OFF 200 MS MANY The LED will flash MANY times...until any key is pressed. With a scope monitor some I/O pins: PA.0 TOGGLE 1 SECONDS 10 TIMES PA.0 will TOGGLE every second ten times. To speed it up: PA.0 HIGH 200 MS PA.0 LOW 200 MS MANY PA.0 will go high for 200 milliseconds then low for 200 ms. This will be repeated MANY times ... until any key is pressed. BEEP 1 SECONDS 10 TIMES Beep speaker once every second ten times. ********************** FLASH186 boots up in DECIMAL base. To change BASE type: HEX for Hex base OCTAL for Octal base BINARY for Binary base DECIMAL back to Decimal base Type .BASE to see what base we are currently in. To create a Forth program to print " HELLO WORLD " : Greeting ." HELLO WORLD" ; Type Greeting ----> HELLO WORLD ** Congratulations! ** You are now a Forth programmer! Type VOCS to see a list of all the available vocabularies. Type ASSEMBLER to select the Assembler vocabulary. Type WORDS to see all the words in it. Type FORTH to restore the Forth vocabulary. Type A: to select A drive Type DIR to view A directory Type B: to select B drive Type DIR to view B directory Type BYE to return to DOS For those interested in learning how to program in FORTH I suggest reading Starting FORTH by Leo Brodie. It is an introduction to the FORTH language and operating system for beginners and professionals. KRM July/2005