FAST Forth Native-Language Embedded Computers
FAST Forth Native-Language Embedded Computers
FAST Forth Native-Language Embedded Computers
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
-<br />
Listing One. Vertical alignment and indenting.<br />
: LPTTYPE ( ADR CNT -- ) ( "TYPE" VERSION FOR PRINTER [LPT] . )<br />
OVER + SWAP ( type WILL CALL THIS IF OUTDEV=LPT. )<br />
?DO ( LOOP LIM & INDX ARE ACTUAL ADDRs. )<br />
I C@ LPTEMIT ( @ & PRINT CHR AT NXT ADR IN STRING.)<br />
OUTERR @ ( SEE IF LPTEMIT HAD ANY PROBLEM. 1<br />
IF CONSOLE LEAVE THEN ( IF LPTEMIT NOT SUCCESSFUL, SET FOR )<br />
LOOP t ( LCD OUTPUT AGAIN & LEAVE THE LOOP. )<br />
Listing Two-a. When nested structures are necessary.<br />
: SAMPLEWORD ( input -- output ) ( comments comments ...I<br />
CONDITIONS IF ( comments comments ... )<br />
ACTIONS ACTIONS ACTIONS ( comments comments ...)<br />
ACTIONS ACTIONS ACTIONS ELSE ( comments comments ...)<br />
CONDITIONS IF ( comments comments ... )<br />
ACTIONS ACTIONS ACTIONS ( comments comments ... )<br />
ACTIONS ACTIONS ACTIONS ELSE ( comments comments ... )<br />
CONDITIONS IF ( comments comments ... )<br />
ACTIONS ACTIONS ACTIONS ( comments comments ... )<br />
ACTIONS ACTIONS ACTIONS ELSE ( comments comments ...I<br />
ACTIONS THEN THEN THEN<br />
I Listing Two-b. The scrambled-eggs version. I<br />
: SAMPLEWORD ( input -- output )<br />
CONDITIONS<br />
IF ACTIONS ACTIONS ACTIONS<br />
ACTIONS ACTIONS ACTIONS<br />
ELSE CONDITIONS<br />
IF ACTIONS ACTIONS ACTIONS<br />
ACTIONS ACTIONS ACTIONS<br />
ELSE CONDITIONS<br />
IF ACTIONS ACTIONS ACTIONS<br />
ACTIONS ACTIONS ACTIONS<br />
ELSE<br />
ACT IONS<br />
THEN<br />
THEN<br />
THEN<br />
made much more mentally manageable by simply lining<br />
things up so the brain can "factor" it. This example has<br />
many factors that the brain should only have to catch once,<br />
greatly simplifying the job of figuring out what someone<br />
else (or maybe you yourself) has written. Listing Three-b<br />
takes care of those.<br />
Listing Four-a shows a colon definition I wrote to figure<br />
out which key or keys, if any, were being pressed on a 16-<br />
key keypad connected through port A (PA) of a 65C22 VL4<br />
(versatile interface adapter) IC. The four most significant<br />
bits were set up to be inputs, and the four least significant<br />
were to be outputs.<br />
There's more description of it farther down. Listing<br />
Four-b shows the same code without the vertical align-<br />
ment. It resembles a kitchen or bathroom you don't even<br />
want to be in (let alone use) because it's so dirty.<br />
Something else crept into Listing Four-&the ; is on<br />
the left margin. This type of thing is done in C a lot (with<br />
the curly braces); but when we see many colons and semi-<br />
colons all on the margin, it takes more attention to tell<br />
<strong>Forth</strong> Dimensions 21 March 1994 April