OSDN Git Service

71f9f6a65a101456888ee2d4c0174be639dfcedd
[fast-forth/master.git] / MSP430-FORTH / FF_SPECS.f
1 \ -*- coding: utf-8 -*-
2 \
3 \ displays all FastForth specifications
4 \ 3 kb free mandatory.
5 \
6 \ FastForth kernel compilation minimal options:
7 \ TERMINAL3WIRES, TERMINAL4WIRES
8 \ MSP430ASSEMBLER, CONDCOMP
9
10 \ TARGET ( = the name of \INC\target.pat file without extension):
11 \ MSP_EXP430FR5739  MSP_EXP430FR5969    MSP_EXP430FR5994    MSP_EXP430FR6989
12 \ MSP_EXP430FR4133  CHIPSTICK_FR2433    MSP_EXP430FR2433    MSP_EXP430FR2355
13 \ LP_MSP430FR2476
14 \ MY_MSP430FR5738_2
15 \ JMJ_BOX_2018_10_29
16 \
17 \ from scite editor : copy your TARGET selection in (shift+F8) parameter 1:
18 \                     copy COMPLEMENT if used in (shift+F8) parameter 2:
19 \
20 \ OR
21 \
22 \ from file explorer :  drag and drop this file onto SendSourceFileToTarget.bat
23 \                       then select your TARGET + COMPLEMENT when asked.
24 \
25 ; ---------------------------------
26 ; FF_SPECS.f
27 ; ---------------------------------
28
29 \ first, we do some tests allowing the download
30     CODE ABORT_FF_SPECS
31     SUB #2,PSP
32     MOV TOS,0(PSP)
33     MOV &VERSION,TOS        \ ARG
34     SUB #400,TOS            \ FastForth V4.0
35     COLON
36     'CR' EMIT               \ return to column 1, no 'LF'
37     ABORT" FastForth V4.0 please!"
38     RST_RET                 \ remove ABORT_FF_SPECS definition before resuming
39     ;
40
41     ABORT_FF_SPECS          \ run tests
42
43 ; ------------------------------------------------------------------
44 ; first we download the set of definitions we need, from CORE_ANS
45 ; ------------------------------------------------------------------
46
47     [UNDEFINED] DUP [IF]    \ define DUP and DUP?
48 \ https://forth-standard.org/standard/core/DUP
49 \ DUP      x -- x x      duplicate top of stack
50     CODE DUP
51 BW1 SUB #2,PSP      \ 2  push old TOS..
52     MOV TOS,0(PSP)  \ 3  ..onto stack
53     MOV @IP+,PC     \ 4
54     ENDCODE
55
56 \ https://forth-standard.org/standard/core/qDUP
57 \ ?DUP     x -- 0 | x x    DUP if nonzero
58     CODE ?DUP
59     CMP #0,TOS      \ 2  test for TOS nonzero
60     0<> ?GOTO BW1   \ 2
61     MOV @IP+,PC     \ 4
62     ENDCODE
63     [THEN]
64
65     [UNDEFINED] OVER [IF]
66 \ https://forth-standard.org/standard/core/OVER
67 \ OVER    x1 x2 -- x1 x2 x1
68     CODE OVER
69     MOV TOS,-2(PSP)     \ 3 -- x1 (x2) x2
70     MOV @PSP,TOS        \ 2 -- x1 (x2) x1
71     SUB #2,PSP          \ 1 -- x1 x2 x1
72     MOV @IP+,PC
73     ENDCODE
74     [THEN]
75
76     [UNDEFINED] DROP [IF]
77 \ https://forth-standard.org/standard/core/DROP
78 \ DROP     x --          drop top of stack
79     CODE DROP
80     MOV @PSP+,TOS   \ 2
81     MOV @IP+,PC     \ 4
82     ENDCODE
83     [THEN]
84
85     [UNDEFINED] SWAP [IF]
86 \ https://forth-standard.org/standard/core/SWAP
87 \ SWAP     x1 x2 -- x2 x1    swap top two items
88     CODE SWAP
89     MOV @PSP,W      \ 2
90     MOV TOS,0(PSP)  \ 3
91     MOV W,TOS       \ 1
92     MOV @IP+,PC     \ 4
93     ENDCODE
94     [THEN]
95
96     [UNDEFINED] ROT [IF]
97 \ https://forth-standard.org/standard/core/ROT
98 \ ROT    x1 x2 x3 -- x2 x3 x1
99     CODE ROT
100     MOV @PSP,W          \ 2 fetch x2
101     MOV TOS,0(PSP)      \ 3 store x3
102     MOV 2(PSP),TOS      \ 3 fetch x1
103     MOV W,2(PSP)        \ 3 store x2
104     MOV @IP+,PC
105     ENDCODE
106     [THEN]
107
108     [UNDEFINED] >R [IF]
109 \ https://forth-standard.org/standard/core/toR
110 \ >R    x --   R: -- x   push to return stack
111     CODE >R
112     PUSH TOS
113     MOV @PSP+,TOS
114     MOV @IP+,PC
115     ENDCODE
116     [THEN]
117
118     [UNDEFINED] R> [IF]
119 \ https://forth-standard.org/standard/core/Rfrom
120 \ R>    -- x    R: x --   pop from return stack ; CALL #RFROM performs DOVAR
121     CODE R>
122     SUB #2,PSP      \ 1
123     MOV TOS,0(PSP)  \ 3
124     MOV @RSP+,TOS   \ 2
125     MOV @IP+,PC     \ 4
126     ENDCODE
127     [THEN]
128
129     [UNDEFINED] 0< [IF]
130 \ https://forth-standard.org/standard/core/Zeroless
131 \ 0<     n -- flag      true if TOS negative
132     CODE 0<
133     ADD TOS,TOS     \ 1 set carry if TOS negative
134     SUBC TOS,TOS    \ 1 TOS=-1 if carry was clear
135     XOR #-1,TOS     \ 1 TOS=-1 if carry was set
136     MOV @IP+,PC     \
137     ENDCODE
138     [THEN]
139
140     [UNDEFINED] = [IF]
141 \ https://forth-standard.org/standard/core/Equal
142 \ =      x1 x2 -- flag         test x1=x2
143     CODE =
144     SUB @PSP+,TOS   \ 2
145     0<> IF          \ 2
146         AND #0,TOS  \ 1 flag Z = 1
147         MOV @IP+,PC \ 4
148     THEN
149     XOR #-1,TOS     \ 1
150     MOV @IP+,PC     \ 4
151     ENDCODE
152     [THEN]
153
154     [UNDEFINED] U< [IF] \ define U> and U>
155 \ https://forth-standard.org/standard/core/Uless
156 \ U<    u1 u2 -- flag       test u1<u2, unsigned
157     CODE U<
158     SUB @PSP+,TOS   \ 2 u2-u1
159     U< ?GOTO FW1
160     0<> IF
161 BW1 MOV #-1,TOS     \ 1
162     THEN
163     MOV @IP+,PC     \ 4
164     ENDCODE
165
166 \ https://forth-standard.org/standard/core/Umore
167 \ U>     n1 n2 -- flag
168     CODE U>
169     SUB @PSP+,TOS   \ 2
170     U< ?GOTO BW1    \ 2 flag = true, Z = 0
171 FW1 AND #0,TOS      \ 1 Z = 1
172     MOV @IP+,PC     \ 4
173     ENDCODE
174     [THEN]
175
176     [UNDEFINED] IF [IF]     \ define IF and THEN
177 \ https://forth-standard.org/standard/core/IF
178 \ IF       -- IFadr    initialize conditional forward branch
179     CODE IF
180     SUB #2,PSP              \
181     MOV TOS,0(PSP)          \
182     MOV &DP,TOS             \ -- HERE
183     ADD #4,&DP              \           compile one word, reserve one word
184     MOV #QFBRAN,0(TOS)      \ -- HERE   compile QFBRAN
185     ADD #2,TOS              \ -- HERE+2=IFadr
186     MOV @IP+,PC
187     ENDCODE IMMEDIATE
188
189 \ https://forth-standard.org/standard/core/THEN
190 \ THEN     IFadr --                resolve forward branch
191     CODE THEN
192     MOV &DP,0(TOS)          \ -- IFadr
193     MOV @PSP+,TOS           \ --
194     MOV @IP+,PC
195     ENDCODE IMMEDIATE
196     [THEN]
197
198     [UNDEFINED] ELSE [IF]
199 \ https://forth-standard.org/standard/core/ELSE
200 \ ELSE     IFadr -- ELSEadr        resolve forward IF branch, leave ELSEadr on stack
201     CODE ELSE
202     ADD #4,&DP              \ make room to compile two words
203     MOV &DP,W               \ W=HERE+4
204     MOV #BRAN,-4(W)
205     MOV W,0(TOS)            \ HERE+4 ==> [IFadr]
206     SUB #2,W                \ HERE+2
207     MOV W,TOS               \ -- ELSEadr
208     MOV @IP+,PC
209     ENDCODE IMMEDIATE
210     [THEN]
211
212     [UNDEFINED] BEGIN [IF]  \ define BEGIN UNTIL AGAIN WHILE REPEAT
213
214 \ https://forth-standard.org/standard/core/BEGIN
215 \ BEGIN    -- BEGINadr             initialize backward branch
216     CODE BEGIN
217     MOV #BEGIN,PC
218     ENDCODE IMMEDIATE
219
220 \ https://forth-standard.org/standard/core/UNTIL
221 \ UNTIL    BEGINadr --             resolve conditional backward branch
222     CODE UNTIL              \ immediate
223     MOV #QFBRAN,X
224 BW1 ADD #4,&DP          \ compile two words
225     MOV &DP,W           \ W = HERE
226     MOV X,-4(W)         \ compile Bran or QFBRAN at HERE
227     MOV TOS,-2(W)       \ compile bakcward adr at HERE+2
228     MOV @PSP+,TOS
229     MOV @IP+,PC
230     ENDCODE IMMEDIATE
231
232 \ https://forth-standard.org/standard/core/AGAIN
233 \ AGAIN    BEGINadr --             resolve uncondionnal backward branch
234     CODE AGAIN
235     MOV #BRAN,X
236     GOTO BW1
237     ENDCODE IMMEDIATE
238
239 \ https://forth-standard.org/standard/core/WHILE
240 \ WHILE    BEGINadr -- WHILEadr BEGINadr
241     : WHILE
242     POSTPONE IF SWAP
243     ; IMMEDIATE
244
245 \ https://forth-standard.org/standard/core/REPEAT
246 \ REPEAT   WHILEadr BEGINadr --     resolve WHILE loop
247     : REPEAT
248     POSTPONE AGAIN POSTPONE THEN
249     ; IMMEDIATE
250     [THEN]
251
252     [UNDEFINED] DO [IF] \ define DO LOOP +LOOP
253
254     HDNCODE XDO         \ DO run time
255     MOV #$8000,X        \ 2 compute 8000h-limit = "fudge factor"
256     SUB @PSP+,X         \ 2
257     MOV TOS,Y           \ 1 loop ctr = index+fudge
258     ADD X,Y             \ 1 Y = INDEX
259     PUSHM #Z,X          \ 4 PUSHM X,Y, i.e. PUSHM LIMIT, INDEX
260     MOV @PSP+,TOS       \ 2
261     MOV @IP+,PC         \ 4
262     ENDCODE
263
264 \ https://forth-standard.org/standard/core/DO
265 \ DO       -- DOadr   L: -- 0
266     CODE DO
267     SUB #2,PSP              \
268     MOV TOS,0(PSP)          \
269     ADD #2,&DP              \   make room to compile xdo
270     MOV &DP,TOS             \ -- HERE+2
271     MOV #XDO,-2(TOS)        \   compile xdo
272     ADD #2,&LEAVEPTR        \ -- HERE+2     LEAVEPTR+2
273     MOV &LEAVEPTR,W         \
274     MOV #0,0(W)             \ -- HERE+2     L-- 0
275     MOV @IP+,PC
276     ENDCODE IMMEDIATE
277
278     HDNCODE XLOOP       \   LOOP run time
279     ADD #1,0(RSP)       \ 4 increment INDEX
280 BW1 BIT #$100,SR        \ 2 is overflow bit set?
281     0= IF               \   branch if no overflow
282         MOV @IP,IP
283         MOV @IP+,PC
284     THEN
285     ADD #4,RSP          \ 1 empties RSP
286     ADD #2,IP           \ 1 overflow = loop done, skip branch ofs
287     MOV @IP+,PC         \ 4 14~ taken or not taken xloop/loop
288     ENDCODE             \
289
290 \ https://forth-standard.org/standard/core/LOOP
291 \ LOOP    DOadr --         L-- an an-1 .. a1 0
292     CODE LOOP
293     MOV #XLOOP,X
294 BW2 ADD #4,&DP              \ make room to compile two words
295     MOV &DP,W
296     MOV X,-4(W)             \ xloop --> HERE
297     MOV TOS,-2(W)           \ DOadr --> HERE+2
298     BEGIN                   \ resolve all "leave" adr
299         MOV &LEAVEPTR,TOS   \ -- Adr of top LeaveStack cell
300         SUB #2,&LEAVEPTR    \ --
301         MOV @TOS,TOS        \ -- first LeaveStack value
302         CMP #0,TOS          \ -- = value left by DO ?
303     0<> WHILE
304         MOV W,0(TOS)        \ move adr after loop as UNLOOP adr
305     REPEAT
306     MOV @PSP+,TOS
307     MOV @IP+,PC
308     ENDCODE IMMEDIATE
309
310     HDNCODE XPLOO   \   +LOOP run time
311     ADD TOS,0(RSP)  \ 4 increment INDEX by TOS value
312     MOV @PSP+,TOS   \ 2 get new TOS, doesn't change flags
313     GOTO BW1        \ 2
314     ENDCODE         \
315
316 \ https://forth-standard.org/standard/core/PlusLOOP
317 \ +LOOP   adrs --   L-- an an-1 .. a1 0
318     CODE +LOOP
319     MOV #XPLOO,X
320     GOTO BW2
321     ENDCODE IMMEDIATE
322     [THEN]
323
324     [UNDEFINED] I [IF]
325 \ https://forth-standard.org/standard/core/I
326 \ I        -- n   R: sys1 sys2 -- sys1 sys2
327 \                  get the innermost loop index
328     CODE I
329     SUB #2,PSP              \ 1 make room in TOS
330     MOV TOS,0(PSP)          \ 3
331     MOV @RSP,TOS            \ 2 index = loopctr - fudge
332     SUB 2(RSP),TOS          \ 3
333     MOV @IP+,PC             \ 4 13~
334     ENDCODE
335     [THEN]
336
337     [UNDEFINED] HERE [IF]
338     CODE HERE
339     MOV #BEGIN,PC
340     ENDCODE
341     [THEN]
342
343     [UNDEFINED] C@ [IF]
344 \ https://forth-standard.org/standard/core/CFetch
345 \ C@     c-addr -- char   fetch char from memory
346     CODE C@
347     MOV.B @TOS,TOS
348     MOV @IP+,PC
349     ENDCODE
350     [THEN]
351
352     [UNDEFINED] SPACES [IF]
353 \ https://forth-standard.org/standard/core/SPACES
354 \ SPACES   n --            output n spaces
355     CODE SPACES
356     CMP #0,TOS
357     0<> IF
358         PUSH IP
359         BEGIN
360             LO2HI
361             'SP' EMIT
362             HI2LO
363             SUB #1,TOS
364         0= UNTIL
365         MOV @RSP+,IP
366     THEN
367     MOV @PSP+,TOS           \ --         drop n
368     MOV @IP+,PC
369     ENDCODE
370     [THEN]
371
372     [UNDEFINED] 1+ [IF]
373 \ https://forth-standard.org/standard/core/OnePlus
374 \ 1+      n1/u1 -- n2/u2       add 1 to TOS
375     CODE 1+
376     ADD #1,TOS
377     MOV @IP+,PC
378     ENDCODE
379     [THEN]
380
381     [UNDEFINED] + [IF]
382 \ https://forth-standard.org/standard/core/Plus
383 \ +       n1/u1 n2/u2 -- n3/u3     add n1+n2
384     CODE +
385     ADD @PSP+,TOS
386     MOV @IP+,PC
387     ENDCODE
388     [THEN]
389
390     [UNDEFINED] - [IF]
391 \ https://forth-standard.org/standard/core/Minus
392 \ -      n1/u1 n2/u2 -- n3/u3     n3 = n1-n2
393     CODE -
394     SUB @PSP+,TOS   \ 2  -- n2-n1 ( = -n3)
395     XOR #-1,TOS     \ 1
396     ADD #1,TOS      \ 1  -- n3 = -(n2-n1) = n1-n2
397     MOV @IP+,PC
398     ENDCODE
399     [THEN]
400
401     [UNDEFINED] 2* [IF]
402 \ https://forth-standard.org/standard/core/TwoTimes
403 \ 2*      x1 -- x2         arithmetic left shift
404     CODE 2*
405     ADD TOS,TOS
406     MOV @IP+,PC
407     ENDCODE
408     [THEN]
409
410     [UNDEFINED] 2/ [IF]
411 \ https://forth-standard.org/standard/core/TwoDiv
412 \ 2/      x1 -- x2        arithmetic right shift
413     CODE 2/
414     RRA TOS
415     MOV @IP+,PC
416     ENDCODE
417     [THEN]
418
419     [UNDEFINED] UM/MOD [IF]
420 \ https://forth-standard.org/standard/core/UMDivMOD
421 \ UM/MOD   udlo|udhi u1 -- r q   unsigned 32/16->r16 q16
422     CODE UM/MOD
423     PUSH #DROP      \
424     MOV #MUSMOD,PC  \ execute MUSMOD then return to DROP
425     ENDCODE
426     [THEN]
427
428     [UNDEFINED] MOVE [IF]
429 \ https://forth-standard.org/standard/core/MOVE
430 \ MOVE    addr1 addr2 u --     smart move
431 \             VERSION FOR 1 ADDRESS UNIT = 1 CHAR
432     CODE MOVE
433     MOV TOS,W           \ W = cnt
434     MOV @PSP+,Y         \ Y = addr2 = dst
435     MOV @PSP+,X         \ X = addr1 = src
436     MOV @PSP+,TOS       \ pop new TOS
437     CMP #0,W            \ count = 0 ?
438     0<> IF              \ if 0, already done !
439         CMP X,Y         \ Y-X \ dst - src
440         0<> IF          \ if dst = src, already done !
441             U< IF       \ U< if src > dst
442                 BEGIN   \ copy W bytes
443                     MOV.B @X+,0(Y)
444                     ADD #1,Y
445                     SUB #1,W
446                 0= UNTIL
447                 MOV @IP+,PC
448             THEN        \ U>= if dst > src
449             ADD W,Y     \ copy W bytes beginning with the end
450             ADD W,X
451             BEGIN
452                 SUB #1,X
453                 SUB #1,Y
454                 MOV.B @X,0(Y)
455                 SUB #1,W
456             0= UNTIL
457         THEN
458     THEN
459     MOV @IP+,PC
460     ENDCODE
461     [THEN]
462
463     [UNDEFINED] CR [IF]
464 \ https://forth-standard.org/standard/core/CR
465 \ CR      --               send CR+LF to the output device
466
467 \ create a primary defered word, i.e. with its default runtime beginning at the >BODY of the definition
468     CODE CR     \ part I : DEFERed definition of CR
469     MOV #NEXT_ADR,PC                \ [PFA] = NEXT_ADR
470     ENDCODE
471
472     :NONAME     \ part II : :NONAME part as default runtime of CR
473     'CR' EMIT 'LF' EMIT
474     ; IS CR                         \ set [PFA] of CR = >BODY addr of CR = CFA of :NONAME part
475
476     [THEN]
477
478     [UNDEFINED] CASE [IF]   \ define CASE OF ENDOF ENDCASE
479
480 \ https://forth-standard.org/standard/core/CASE
481     : CASE
482     0
483     ; IMMEDIATE \ -- #of-1
484
485 \ https://forth-standard.org/standard/core/OF
486     : OF \ #of-1 -- orgOF #of
487     1+                      \ count OFs
488     >R                      \ move off the stack in case the control-flow stack is the data stack.
489     POSTPONE OVER
490     POSTPONE =              \ copy and test case value
491     POSTPONE IF             \ add orig to control flow stack
492     POSTPONE DROP               \ discards case value if =
493     R>                      \ we can bring count back now
494     ; IMMEDIATE
495
496 \ https://forth-standard.org/standard/core/ENDOF
497     : ENDOF \ orgOF #of -- orgENDOF #of
498     >R                      \ move off the stack in case the control-flow stack is the data stack.
499     POSTPONE ELSE
500     R>                      \ we can bring count back now
501     ; IMMEDIATE
502
503 \ https://forth-standard.org/standard/core/ENDCASE
504     : ENDCASE \ orgENDOF1..orgENDOFn #of --
505     POSTPONE DROP
506     0 DO
507         POSTPONE THEN
508     LOOP
509     ; IMMEDIATE
510     [THEN]
511
512 ; --------------------------
513 ; end of definitions we need
514 ; --------------------------
515
516     [UNDEFINED] S? [IF] \
517     CODE S?             \           to compile: sep S? <string>sep
518     MOV #S"+10,PC       \           (S" + 10) --> PC
519     ENDCODE IMMEDIATE
520     [THEN]
521
522     [UNDEFINED] ESC [IF]
523     CODE ESC
524     CMP #0,&STATEADR
525     0= IF MOV @IP+,PC   \ interpret time usage disallowed
526     THEN
527     COLON
528     'ESC'               \ -- char escape
529     POSTPONE LITERAL    \ compile-time code : lit 'ESC'
530     POSTPONE EMIT       \ compile-time code : EMIT
531     'SP'                \ char SPACE as separator for next string
532     POSTPONE S?         \ compile-time code : S?
533     POSTPONE TYPE       \ compile-time code : TYPE
534     ; IMMEDIATE
535     [THEN]
536
537     [DEFINED] FORTH [IF]    \ word-set addon ?
538     CODE BODY>SQNFA     \ BODY -- ADR cnt             BODY > SQuoteNFA
539     SUB #2,PSP
540     SUB #4,TOS
541     MOV TOS,Y           \ Y = CFA
542     MOV Y,X             \ X = CFA
543     BEGIN
544         SUB #2,X
545         MOV X,0(PSP)    \ -- string_test_address CFA
546         MOV.B @X+,TOS   \ -- string_test_address cnt_test
547         RRA TOS         \ -- string_test_address cnt_test/2
548         MOV TOS,W
549         BIT #1,W        \           cnt_test even ?
550         0= IF
551             ADD #1,W    \           if yes add #1,TOS
552         THEN
553         ADD X,W         \           string_test_address + cnt_test
554         CMP W,Y         \           string_test_address + cnt_test = CFA ?
555     0<> WHILE           \           out of loop if yes
556         MOV @PSP,X      \           loop back to test with X - one_word
557     REPEAT
558     MOV X,0(PSP)        \ -- string_addr string_cnt of NFA
559     MOV @IP+,PC
560     ENDCODE
561     [THEN]
562
563     : SPECS             \ to see all FastForth specifications
564 \
565     RST_RET             \ before computing free bytes, remove all FF_SPECS previous definitions
566     ECHO
567     ESC [8;42;80t       \ set 42L * 80C terminal display
568 \
569 \   title in reverse video
570     ESC [7m             \ Turn reverse video on
571     CR ." FastForth V"
572     VERSION @
573     0 <# # 'BS' HOLD # '.' HOLD #S #> TYPE
574     ."  for MSP430FR"
575     HERE                \ HERE - MAIN_ORG = bytes code
576     DEVICEID @          \ value kept in TLV area
577     CASE
578 \
579 \ device_ID OF  ." xxxx," $MAIN_ORG ENDOF \ <-- add here your device
580     $8102   OF  ." 5738,"   $C200   ENDOF
581     $8103   OF  ." 5739,"   $C200   ENDOF
582     $810D   OF  ." 5986,"   $4400   ENDOF
583     $8160   OF  ." 5948,"   $4400   ENDOF
584     $8169   OF  ." 5969,"   $4400   ENDOF
585     $81A8   OF  ." 6989,"   $4400   ENDOF
586     $81F0   OF  ." 4133,"   $C400   ENDOF
587     $8240   OF  ." 2433,"   $C400   ENDOF
588     $825D   OF  ." 5972,"   $4400   ENDOF
589     $82A1   OF  ." 5994,"   $4000   ENDOF
590     $830C   OF  ." 2355,"   $8000   ENDOF
591     $830D   OF  ." 2353,"   $C000   ENDOF
592     $831E   OF  ." 2155,"   $8000   ENDOF
593     $831D   OF  ." 2153,"   $C000   ENDOF
594     $832A   OF  ." 2476,"   $8000   ENDOF
595     $832B   OF  ." 2475,"   $8000   ENDOF
596     $833C   OF  ." 2633,"   $C400   ENDOF
597     $833D   OF  ." 2533,"   $C400   ENDOF
598     ABORT" xxxx <-- unrecognized device!"
599     ENDCASE                             \ -- HERE MAIN_ORG
600     ."  DTC"
601     ['] ['] DUP @ $1284 =               \ DOCOL = CALL rDOCOL opcode
602     IF ." =1," DROP                     \ [CFA] = CALL rDOCOL
603     ELSE 2 + @ $1284 =                  \
604         IF ." =2,"                      \ [CFA] = PUSH IP, [CFA+2] = CALL rDOCOL
605         ELSE ." =3,"                    \ [CFA] = PUSH IP, [CFA+2] = MOV PC,IP
606         THEN
607     THEN
608     'SP' EMIT
609     THREADS @ U. 'BS' EMIT
610     ." -Entry word set, "               \ number of Entry word set,
611     FREQ_KHZ @ 0 1000 UM/MOD U.         \ frequency
612     ?DUP IF 'BS' EMIT ',' EMIT U.       \ if remainder
613     THEN ." MHz, "                      \ MCLK
614     - U. ." bytes"                      \ HERE - MAIN_ORG = number of bytes code,
615     ESC [0m                             \ Turn off character attributes
616 \
617 \   general
618     CR
619     ." /COUNTED-STRING   = 255" CR
620     ." /HOLD             = 34" CR
621     ." /PAD              = 84" CR
622     ." ADDRESS-UNIT-BITS = 16" CR
623     [DEFINED] {CORE_ANS}
624     [IF]
625     ." FLOORED DIVISION  = "
626     KERNEL_ADDON @                      \ negative value if FLOORED DIVISION
627     0< IF ." true"
628     ELSE  ." false"
629     THEN    CR
630     [THEN]
631     ." MAX-CHAR          = 255" CR
632     ." MAX-N             = 32767" CR
633     ." MAX-U             = 65535" CR
634     ." MAX-D             = 2147483647" CR
635     ." MAX-UD            = 4294967295" CR
636     ." STACK-CELLS       = 48" CR
637     ." RETURN-STACK-CELLS= 48" CR
638     ." Definitions are always UPPERCASE." CR
639 \
640 \   kernel specs
641     CR ESC [7m ." Kernel add-ons" ESC [0m CR  \ subtitle in reverse video
642     KERNEL_ADDON @
643     2*  DUP 0< IF ." 32.768kHz LF XTAL" CR THEN             \ BIT14
644     2*  DUP 0< IF ." /RTS /CTS " 2*                         \ BIT13
645             ELSE  2* DUP                                    \ /BIT13
646                 0< IF ." /RTS " THEN                        \ /BIT13 & BIT12
647             THEN
648     2*  DUP 0< IF ." XON/XOFF "  THEN                       \ BIT11
649     2*  DUP 0< IF ." Half-Duplex "  THEN                    \ BIT10
650     2*  DUP 0< IF ." I2C_Master TERMINAL"                   \ BIT9
651             ELSE  ." UART TERMINAL" THEN CR                 \ /BIT9
652     2*  DUP 0< IF 2* DUP 0< IF ." DOUBLE and "                  \  BIT8 + BIT7
653                          THEN  ." Q15.16 numbers handling" CR
654             ELSE  2* DUP 0< IF ." DOUBLE numbers handling" CR   \ /BIT8 + BIT7
655                          THEN
656             THEN
657     2*  DUP 0< IF ." MSP430_X assembler with TI's syntax"
658                     CR 2* 2*                                \ BIT6 BIT5 BIT4
659             ELSE                                            \ /BIT6
660                 2*  DUP
661                 0< IF ." MSP430 Assembler"                  \       BIT5
662                     2*  DUP
663                     0< IF ." , 20bits extended addresses,"  \               BIT4
664                     THEN
665                 ELSE 2*                                     \               BIT4
666                 THEN
667                 ."  with TI's syntax" CR
668             THEN DROP                                       \ BIT2 to BIT0 are free
669     [DEFINED] FORTH [IF] ." word-set management" CR 
670     [THEN]
671     [DEFINED] LOAD" [IF] ." SD_CARD Load" CR
672     [THEN]
673     [DEFINED] BOOT  [IF] ." SD_CARD Bootloader" CR
674     [THEN]
675     [DEFINED] READ" [IF] ." SD_CARD Read/Write" CR
676     [THEN]
677 \
678 \   display word-sets
679     LASTVOC                             \ -- VOCLINK addr.
680     BEGIN
681         @ ?DUP                          \ -- VOCLINK            word-set here ?
682     WHILE                               \ -- VLK
683 \       --------------------------------\
684         CR ESC [7m                      \                       word-set TITLE in reverse video
685         DUP THREADS @ 2* -              \ -- VLK WORDSET_BODY
686         [DEFINED] FORTH                 \                       word-set addon ?
687         [IF] DUP BODY>SQNFA             \ -- VLK WRDST_BODY addr cnt
688         [ELSE]  OVER @                  \ -- VLK WRDST_BODY NEXT_VLINK
689                 IF S" hidden"           \                       if next_vlink <>0
690                 ELSE S" FORTH"          \                       if next_vlink = 0
691                 THEN                    \ -- VLK WRDST_BODY addr cnt
692         [THEN]
693         TYPE ."  word-set"              \ -- VLK WRDST_BODY
694         ESC [0m CR
695 \       --------------------------------\                       block of DEFINITIONS
696 \       : WORDS                         \ VOC_BODY --           customized WORD definition
697         PAD_ORG                         \ -- VOC_BODY PAD                  MOVE all threads from VOC_BODY to PAD_ORG
698         THREADS @ 2*                    \ -- VOC_BODY PAD THREADS*2
699         MOVE                            \ -- vocabulary entries are copied in PAD_ORG
700         BEGIN                           \ --
701             0 DUP                       \ -- ptr=0 MAX=0
702             THREADS @ 2* 0              \ -- ptr=0 MAX=0 THREADS*2 0
703                 DO                      \ -- ptr MAX            I =  PAD_ptr = thread*2
704                 DUP I PAD_ORG + @       \ -- ptr MAX MAX NFAx
705                     U< IF               \ -- ptr MAX            if MAX U< NFAx
706                         DROP DROP       \ --                    drop ptr and MAX
707                         I DUP PAD_ORG + @   \ -- new_ptr new_MAX
708                     THEN                \
709                 2 +LOOP                 \ -- ptr MAX
710             ?DUP                        \ -- ptr MAX MAX | -- ptr 0 (all threads in PAD = 0)
711         WHILE                           \ -- ptr MAX                    replace it by its LFA
712             DUP                         \ -- ptr MAX MAX
713             2 - @                       \ -- ptr MAX [LFA]
714             ROT                         \ -- MAX [LFA] ptr
715             PAD_ORG +                   \ -- MAX [LFA] thread
716             !                           \ -- MAX                MAX=highest_NFA [LFA]=new_NFA updates PAD_ORG+ptr
717             COUNT 2/                    \ -- addr name_count    2/ to hide Immediate flag
718             DUP >R TYPE                 \ --      R-- count
719             $10 R> - SPACES             \ --      R--           complete with spaces modulo 16 chars
720         REPEAT                          \ --
721         DROP                            \ ptr --
722 \       ;                               \ all threads in PAD are filled with 0
723 \       --------------------------------\
724         CR                              \ -- VLINK              definitions display
725     REPEAT
726     DROP
727 \
728 \   extensions
729     CR ESC [7m ." EXTENSIONS" ESC [0m   \ subtitle in reverse video
730     [DEFINED] {CORE_ANS} [IF] CR ." CORE ANS94"
731     [THEN]
732     [DEFINED] {DOUBLE}   [IF] CR ." DOUBLE numbers set"
733     [THEN]
734     [DEFINED] {UTILITY}  [IF] CR ." UTILITY"
735     [THEN]
736     [DEFINED] {FIXPOINT} [IF] CR ." Q15.16 ADD SUB MUL DIV"
737     [THEN]
738     [DEFINED] {CORDIC}   [IF] CR ." CORDIC engine"
739     [THEN]
740     [DEFINED] {SD_TOOLS} [IF] CR ." SD_TOOLS"
741     [THEN]
742     [DEFINED] {RTC}      [IF] CR ." RTC utility"
743     [THEN]
744     [DEFINED] {UARTI2CS} [IF] CR ." UART to I2C_FastForth bridge"
745     [THEN]
746     CR
747     SYS                                 \ WARM
748     ;
749
750 SPECS \ performs RST_RET and displays FastForth specs