27.01.2015 Views

FAST Forth Native-Language Embedded Computers

FAST Forth Native-Language Embedded Computers

FAST Forth Native-Language Embedded Computers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

'1 Listing Five. Include descriptive diagrams with a text editor.<br />

( COL COL COL COL COL COL COL COL COL COL COL COL COL COL COL COL<br />

( 1 1 2 1 3 1 4 1 1 2 1 3 1 4 1 1 2 1 3 1 4 1 1 2 1 3 1 4 1<br />

(<br />

1<br />

(<br />

ROW 1<br />

ROW 2<br />

ROW 3 ROW 4<br />

)<br />

( rnsb<br />

lsb )<br />

(<br />

1<br />

( 1<br />

( )<br />

( COLl COL2 COL3 COL4 1<br />

( PA7 PA6 PA5 PA4 1<br />

(<br />

1<br />

( ROW1 BIT BIT BIT BIT Keyboard front view, with row )<br />

( PA3 15 14 13 12 and column labels. 1<br />

(<br />

Keyboard is a 4x4 matrix. )<br />

( ROW2 BIT BIT BIT BIT Normally all the rows are held )<br />

( PA2 11 10 9 8 low, and when a key is pressed,)<br />

(<br />

one of the columns gets pulled )<br />

( ROW3 BIT BIT BIT BIT down, which also pulls the IRQ )<br />

( PA1 7 6 5 4 [CAI] down [true] to assert the)<br />

(<br />

IRQ to tell the pP to see which)<br />

( ROW4 BIT BIT BIT BIT key was pressed. Actually, we )<br />

( PA0 3 2 1 0 are not using keypad interrupts)<br />

( at this time, but the hardware )<br />

( is there should we want to in )<br />

( the future. )<br />

8000 CONSTANT "KEY<br />

0800 CONSTANT vKEY<br />

( up arrow<br />

( down arrow<br />

0008 CONSTANT MENUKEY<br />

0004 CONSTAPJT YESKEY<br />

0001 CONSTANT NOKEY<br />

CREATE KEY#TBL<br />

4000 , 1 C, 0100 , 6 C,<br />

2009 , 2 C, 0040 , 7 C,<br />

1000 , 3 C, 0020 , 8 C,<br />

0400 , 4 C, 0010 , 9 C,<br />

0200 , 5 C, 0002 , 0 C,<br />

(<br />

(<br />

(<br />

(<br />

(<br />

(<br />

(<br />

(<br />

(<br />

(<br />

(<br />

(<br />

(<br />

h<br />

v<br />

MENU<br />

1<br />

( ENTER EXIT<br />

( CONTINUE<br />

4<br />

7<br />

YES<br />

2<br />

5<br />

8<br />

0<br />

3<br />

6<br />

9<br />

NO<br />

to compiling it (if necessary), to trying it on the targetall<br />

without leaving, suspending, or even backgrounding<br />

the editor. It is set up so no code changes are needed to<br />

make the transition from RAM to ROM for the finished<br />

system. It's very simple, and the only hardware and<br />

software required has been out for years. It's a natural for<br />

<strong>Forth</strong>. (That will be material for another article. In spite of<br />

its simplicity, I haven't found anyone else who has heard<br />

of such a thing, so evidently it does deserve an article.)<br />

Use a text editor where possible, so you have lots of<br />

room for comments, and so you can use more of the<br />

stroms. You can replace (xA2+yA2) A 1 /2 with d (x2+y2)<br />

without any of those hidden word processor control codes<br />

that are hostile toward compilers.<br />

The only drawback is that you may have to modify<br />

L>NAME (or another <strong>Forth</strong> word that takes a CFA or LFA<br />

to find the NFA). This is because it typically backs up until<br />

it encounters the first byte whose high bit is set. This<br />

drawback is minor, since if you don't make the modification,<br />

the only effect you will probably notice is that WORDS<br />

or decompiling words will print the names with special<br />

characters wrong. Just in case the high bit is set in an actual<br />

special characters and have short descriptive names like character of the name itself, L>NAME needs to see if the<br />

loon, OC, $LIFE, or +2%. GO ahead-use A for ang- length indicated by the five least-significant bits agrees<br />

<strong>Forth</strong> Dimensions 23 March 1994 April

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!