FAST Forth Native-Language Embedded Computers
FAST Forth Native-Language Embedded Computers
FAST Forth Native-Language Embedded Computers
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Listing Six. Even add timing diagrams with a text editor.<br />
U I L<br />
(<br />
)<br />
( NORMAL )<br />
( A B C F G A . . . 1<br />
( 1<br />
( 1<br />
( IF JUMPED GUN 1<br />
( A B CD E G A . . . 1<br />
Listing Seven. Use of binary when individual bits are of interest.<br />
: SYNCSERSETUP ( -- )<br />
[BI<br />
VIADDRB C@ 1 OR VIADDRB C! ( SET PBO AS OUTPUT FOR STROBE LINE. )<br />
VIAACR C@ OOOlOlOO OR ( ENABL SR TO SHIFT OUT UNDR T2 CTRL. )<br />
1101O111 AND VIAACR C! ( DECR AT @2 RATE. )<br />
00100100 VIAIER C! ( DISABL SR-EMPTY & T2 IRQs. )<br />
( SET T2 FOR ABT lookHz SHFT RATE, LO )<br />
[HI 8 VIAT2CL C! ( BYT 1ST. T2 GETS RST AUTOMATICALLY )<br />
0 VIAT2CH C! ; ( SO ITS NOT REALLY 1-SHOT IN SR MODE )<br />
with the number of bytes already backed over. If there is<br />
disagreement, it has not arrived yet at the NFA, and it<br />
needs to keep looking. You might see right away that a few<br />
combinations could still fool it. Those are easy enough to<br />
determine and avoid.<br />
A text editor will allow you to use the graphics<br />
characters for diagrams in your comments. The diagrams<br />
in Listing Five are out of an application I did a couple of<br />
years ago. They preceded my keyboard-scan code in<br />
Listing Four-a.<br />
Where an explanation of timing is appropriate to<br />
understanding code, you can even include a timing<br />
diagram. For example, following a timing descriptior! in<br />
the comments on a recent project, I put in the diagrams in<br />
Listing Six to graphically summarize.<br />
The source code should be more than just compiler-<br />
needed input-it should be the major software document.<br />
The diagrams are worthless to a compiler, but are priceless<br />
to someone who has to come along later and figure out<br />
how to update the code.<br />
A text editor like the Norton Editor can also allow you<br />
to look at two files at once with a split screen, and to copy<br />
portions from one to the other, test portions for differ-<br />
ences, etc. The transfer between files is transparent as you<br />
move the cursor with the mouse.<br />
You can scroll. You can use block markers as book<br />
marks which the editor can find instantly after you have<br />
been looking at something elsewhere in the file. You can<br />
use different modes of search, or search-and-replace,<br />
including reverse and case-insensitive. The searches will<br />
be extremely fast, since usually the whole file is in RAM<br />
and disc access is unnecessary. You can flip the case from<br />
the cursor to the beginning or end of the line to transfer<br />
from upper- to lower-case (or vice versa) without retyp-<br />
ing. You can reformat a paragraph, which is useful for<br />
comment paragraphs when you need to insert or delete<br />
something in the middle without messing up all the line<br />
lengths.<br />
If you can forego the few advantages of screen files, a<br />
text editor can give you far more flexibility than the screen<br />
editors I've seen.<br />
More Vertical Alignment<br />
Listing Seven shows a colon definition I used to set up<br />
a synchronous serial port on a 65C22 VIA (versatile<br />
interface adapter) IC. The register names came right out of<br />
the data book, which has register diagrams showing the<br />
bit-by-bit functions. We want to pay attention to individual<br />
bits (not the overall number they make up), and we want<br />
to mask and set or clear individual bits; so it makes sense<br />
to use binary and line them up vertically, just as our<br />
second-grade teachers taught us to do for addition.<br />
Sometimes, immediate do-nothing words are very<br />
helpful for clarifying code. You could have words like<br />
: SAMPLES ; IMMEDIATE<br />
: k ~ z ; IMMEDIATE<br />
to use in a sequence that plays back a specified set of<br />
samples at a specified rate, like<br />
TBLl 2000 SAMPLES 8 kHz PLAYBACK<br />
Alternatively, SAMPLES could, for example, store the<br />
number on the top of the stack for PLAYBACK to use, so<br />
the net stack effect of 20 0 0 SAMPLES would be ( -- ).<br />
Now and then, we hear talk of programming languages<br />
or command structures that are very "English-like," as if it<br />
were a plus. Frankly, English is a lousy pattern for a<br />
programming language to follow. For technical communi-<br />
cation, it's far better than some other languages, yet<br />
confusion still abounds.<br />
March 1994 April 24 <strong>Forth</strong> Dimensions