1 \ -*- coding: utf-8 -*-
3 \ displays all FastForth specifications
6 \ TARGET ( = the name of \INC\target.pat file without the extension):
7 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
8 \ MSP_EXP430FR4133 CHIPSTICK_FR2433 MSP_EXP430FR2433 MSP_EXP430FR2355
13 \ from scite editor : copy your TARGET selection in (shift+F8) parameter 1:
14 \ copy COMPLEMENT if used in (shift+F8) parameter 2:
18 \ from file explorer : drag and drop this file onto SendSourceFileToTarget.bat
19 \ then select your TARGET + COMPLEMENT when asked.
21 \ if you choice a bad target, you will obtain an error during downloading: "Device's ID mismatch!"
23 \ COLD \ uncomment for this TEST which must not disrupt the downloading process
25 ; ---------------------------------
27 ; ---------------------------------
29 \ first, we test for downloading driver only if UART TERMINAL target
34 SUB #307,TOS \ FastForth V3.7
36 'CR' EMIT \ return to column 1 without 'LF'
37 ABORT" FastForth version = 3.7 please!"
38 PWR_STATE \ remove ABORT_FF_SPECS definition before resuming
44 \ https://forth-standard.org/standard/core/AND
45 \ C AND x1 x2 -- x3 logical AND
52 [UNDEFINED] DUP [IF] \ define DUP and DUP?
53 \ https://forth-standard.org/standard/core/DUP
54 \ DUP x -- x x duplicate top of stack
56 BW1 SUB #2,PSP \ 2 push old TOS..
57 MOV TOS,0(PSP) \ 3 ..onto stack
61 \ https://forth-standard.org/standard/core/qDUP
62 \ ?DUP x -- 0 | x x DUP if nonzero
64 CMP #0,TOS \ 2 test for TOS nonzero
71 \ https://forth-standard.org/standard/core/OVER
72 \ OVER x1 x2 -- x1 x2 x1
74 MOV TOS,-2(PSP) \ 3 -- x1 (x2) x2
75 MOV @PSP,TOS \ 2 -- x1 (x2) x1
76 SUB #2,PSP \ 1 -- x1 x2 x1
82 \ https://forth-standard.org/standard/core/DROP
83 \ DROP x -- drop top of stack
91 \ https://forth-standard.org/standard/core/SWAP
92 \ SWAP x1 x2 -- x2 x1 swap top two items
102 \ https://forth-standard.org/standard/core/ROT
103 \ ROT x1 x2 x3 -- x2 x3 x1
105 MOV @PSP,W \ 2 fetch x2
106 MOV TOS,0(PSP) \ 3 store x3
107 MOV 2(PSP),TOS \ 3 fetch x1
108 MOV W,2(PSP) \ 3 store x2
114 \ https://forth-standard.org/standard/core/toR
115 \ >R x -- R: -- x push to return stack
124 \ https://forth-standard.org/standard/core/Rfrom
125 \ R> -- x R: x -- pop from return stack ; CALL #RFROM performs DOVAR
135 \ https://forth-standard.org/standard/core/ZeroEqual
136 \ 0= n/u -- flag return true if TOS=0
138 SUB #1,TOS \ borrow (clear cy) if TOS was 0
139 SUBC TOS,TOS \ TOS=-1 if borrow was set
145 \ https://forth-standard.org/standard/core/Zeroless
146 \ 0< n -- flag true if TOS negative
148 ADD TOS,TOS \ 1 set carry if TOS negative
149 SUBC TOS,TOS \ 1 TOS=-1 if carry was clear
150 XOR #-1,TOS \ 1 TOS=-1 if carry was set
156 \ https://forth-standard.org/standard/core/Equal
157 \ = x1 x2 -- flag test x1=x2
161 AND #0,TOS \ 1 flag Z = 1
169 \ https://forth-standard.org/standard/core/Uless
170 \ U< u1 u2 -- flag test u1<u2, unsigned
173 SUB @PSP+,TOS \ 2 u2-u1
177 AND #0,TOS \ 1 flag Z = 1
184 [UNDEFINED] IF [IF] \ define IF and THEN
185 \ https://forth-standard.org/standard/core/IF
186 \ IF -- IFadr initialize conditional forward branch
190 MOV &DP,TOS \ -- HERE
191 ADD #4,&DP \ compile one word, reserve one word
192 MOV #QFBRAN,0(TOS) \ -- HERE compile QFBRAN
193 ADD #2,TOS \ -- HERE+2=IFadr
197 \ https://forth-standard.org/standard/core/THEN
198 \ THEN IFadr -- resolve forward branch
200 MOV &DP,0(TOS) \ -- IFadr
206 [UNDEFINED] ELSE [IF]
207 \ https://forth-standard.org/standard/core/ELSE
208 \ ELSE IFadr -- ELSEadr resolve forward IF branch, leave ELSEadr on stack
210 ADD #4,&DP \ make room to compile two words
213 MOV W,0(TOS) \ HERE+4 ==> [IFadr]
215 MOV W,TOS \ -- ELSEadr
220 [UNDEFINED] BEGIN [IF] \ define BEGIN UNTIL AGAIN WHILE REPEAT
221 \ https://forth-standard.org/standard/core/BEGIN
222 \ BEGIN -- BEGINadr initialize backward branch
228 [UNDEFINED] UNTIL [IF] \ define BEGIN UNTIL AGAIN WHILE REPEAT
229 \ https://forth-standard.org/standard/core/UNTIL
230 \ UNTIL BEGINadr -- resolve conditional backward branch
233 BW1 ADD #4,&DP \ compile two words
235 MOV X,-4(W) \ compile Bran or QFBRAN at HERE
236 MOV TOS,-2(W) \ compile bakcward adr at HERE+2
241 \ https://forth-standard.org/standard/core/AGAIN
242 \ AGAIN BEGINadr -- resolve uncondionnal backward branch
249 [UNDEFINED] WHILE [IF] \ define DO LOOP +LOOP
250 \ https://forth-standard.org/standard/core/WHILE
251 \ WHILE BEGINadr -- WHILEadr BEGINadr
257 [UNDEFINED] REPEAT [IF] \ define DO LOOP +LOOP
258 \ https://forth-standard.org/standard/core/REPEAT
259 \ REPEAT WHILEadr BEGINadr -- resolve WHILE loop
261 POSTPONE AGAIN POSTPONE THEN
265 [UNDEFINED] DO [IF] \ define DO LOOP +LOOP
266 \ https://forth-standard.org/standard/core/DO
267 \ DO -- DOadr L: -- 0
271 ADD #2,&DP \ make room to compile xdo
272 MOV &DP,TOS \ -- HERE+2
273 MOV #XDO,-2(TOS) \ compile xdo
274 ADD #2,&LEAVEPTR \ -- HERE+2 LEAVEPTR+2
276 MOV #0,0(W) \ -- HERE+2 L-- 0
280 \ https://forth-standard.org/standard/core/LOOP
281 \ LOOP DOadr -- L-- an an-1 .. a1 0
284 BW1 ADD #4,&DP \ make room to compile two words
286 MOV X,-4(W) \ xloop --> HERE
287 MOV TOS,-2(W) \ DOadr --> HERE+2
288 BEGIN \ resolve all "leave" adr
289 MOV &LEAVEPTR,TOS \ -- Adr of top LeaveStack cell
290 SUB #2,&LEAVEPTR \ --
291 MOV @TOS,TOS \ -- first LeaveStack value
292 CMP #0,TOS \ -- = value left by DO ?
294 MOV W,0(TOS) \ move adr after loop as UNLOOP adr
300 \ https://forth-standard.org/standard/core/PlusLOOP
301 \ +LOOP adrs -- L-- an an-1 .. a1 0
304 GOTO BW1 \ goto BW1 LOOP
309 \ https://forth-standard.org/standard/core/I
310 \ I -- n R: sys1 sys2 -- sys1 sys2
311 \ get the innermost loop index
313 SUB #2,PSP \ 1 make room in TOS
315 MOV @RSP,TOS \ 2 index = loopctr - fudge
321 [UNDEFINED] HERE [IF]
328 \ https://forth-standard.org/standard/core/CFetch
329 \ C@ c-addr -- char fetch char from memory
336 [UNDEFINED] SPACES [IF]
337 \ https://forth-standard.org/standard/core/SPACES
338 \ SPACES n -- output n spaces
352 MOV @PSP+,TOS \ -- drop n
358 \ https://forth-standard.org/standard/core/OnePlus
359 \ 1+ n1/u1 -- n2/u2 add 1 to TOS
367 \ https://forth-standard.org/standard/core/Plus
368 \ + n1/u1 n2/u2 -- n3/u3 add n1+n2
376 \ https://forth-standard.org/standard/core/Minus
377 \ - n1/u1 n2/u2 -- n3/u3 n3 = n1-n2
379 SUB @PSP+,TOS \ 2 -- n2-n1 ( = -n3)
381 ADD #1,TOS \ 1 -- n3 = -(n2-n1) = n1-n2
387 \ https://forth-standard.org/standard/core/TwoTimes
388 \ 2* x1 -- x2 arithmetic left shift
395 [UNDEFINED] UM/MOD [IF]
396 \ https://forth-standard.org/standard/core/UMDivMOD
397 \ UM/MOD udlo|udhi u1 -- r q unsigned 32/16->r16 q16
400 MOV #MUSMOD,PC \ execute MUSMOD then return to DROP
404 [UNDEFINED] MOVE [IF]
405 \ https://forth-standard.org/standard/core/MOVE
406 \ MOVE addr1 addr2 u -- smart move
407 \ VERSION FOR 1 ADDRESS UNIT = 1 CHAR
410 MOV @PSP+,Y \ Y = addr2 = dst
411 MOV @PSP+,X \ X = addr1 = src
412 MOV @PSP+,TOS \ pop new TOS
413 CMP #0,W \ count = 0 ?
414 0<> IF \ if 0, already done !
415 CMP X,Y \ Y-X \ dst - src
416 0<> IF \ if dst = src, already done !
417 U< IF \ U< if src > dst
424 THEN \ U>= if dst > src
425 ADD W,Y \ copy W bytes beginning with the end
439 [UNDEFINED] WORDS [IF]
440 \ https://forth-standard.org/standard/tools/WORDS
441 \ list all words of vocabulary first in CONTEXT.
444 CONTEXT @ PAD_ORG \ -- VOC_BODY PAD MOVE all threads of VOC_BODY in PAD_ORG
445 THREADS @ 2* \ -- VOC_BODY PAD THREADS*2
446 MOVE \ -- vocabulary entries are copied in PAD_ORG
448 0 DUP \ -- ptr=0 MAX=0
449 THREADS @ 2* 0 \ -- ptr=0 MAX=0 THREADS*2 0
450 DO \ -- ptr MAX I = PAD_ptr = thread*2
451 DUP I PAD_ORG + @ \ -- ptr MAX MAX NFAx
452 U< IF \ -- ptr MAX if MAX U< NFAx
453 DROP DROP \ -- drop ptr and MAX
454 I DUP PAD_ORG + @ \ -- new_ptr new_MAX
457 ?DUP \ -- ptr MAX MAX | -- ptr 0 (all threads in PAD = 0)
458 WHILE \ -- ptr MAX replace it by its LFA
460 2 - @ \ -- ptr MAX [LFA]
461 ROT \ -- MAX [LFA] ptr
462 PAD_ORG + \ -- MAX [LFA] thread
463 ! \ -- MAX [LFA]=new_NFA updates PAD+ptr
465 COUNT $7F AND \ -- MAX addr count (with suppr. of immediate bit)
467 C@ $0F AND \ -- count_of_chars
468 $10 SWAP - SPACES \ -- complete with spaces modulo 16 chars
471 ; \ all threads in PAD are filled with 0
474 [UNDEFINED] CASE [IF]
475 \ https://forth-standard.org/standard/core/CASE
476 : CASE 0 ; IMMEDIATE \ -- #of-1
478 \ https://forth-standard.org/standard/core/OF
479 : OF \ #of-1 -- orgOF #of
481 >R \ move off the stack in case the control-flow stack is the data stack.
482 POSTPONE OVER POSTPONE = \ copy and test case value
483 POSTPONE IF \ add orig to control flow stack
484 POSTPONE DROP \ discards case value if =
485 R> \ we can bring count back now
488 \ https://forth-standard.org/standard/core/ENDOF
489 : ENDOF \ orgOF #of -- orgENDOF #of
490 >R \ move off the stack in case the control-flow stack is the data stack.
492 R> \ we can bring count back now
495 \ https://forth-standard.org/standard/core/ENDCASE
496 : ENDCASE \ orgENDOF1..orgENDOFn #of --
505 CODE S_ \ Squote alias with blank instead quote separator
506 MOV #0,&CAPS \ turn CAPS OFF
508 XSQUOTE , \ compile run-time code
509 'SP' WORD \ -- c-addr (= HERE)
511 MOV.B @TOS,TOS \ -- len compile string
512 ADD #1,TOS \ -- len+1
514 ADDC TOS,&DP \ store aligned DP
516 MOV @RSP+,IP \ pop paired with push COLON
517 MOV #$20,&CAPS \ turn CAPS ON (default state)
525 0= IF MOV @IP+,PC \ interpret time usage disallowed
528 'ESC' \ -- char escape
529 POSTPONE LITERAL \ compile-time code : lit 'ESC'
530 POSTPONE EMIT \ compile-time code : EMIT
531 POSTPONE S_ \ compile-time code : S_ <escape_sequence>
532 POSTPONE TYPE \ compile-time code : TYPE
536 \ -------------------------------------------------------
537 : SPECS \ to see all FastForth specifications
538 \ -------------------------------------------------------
539 PWR_STATE \ before computing free bytes, remove all created words
541 ESC [8;40;80t \ set 40L * 80C terminal display
542 39 0 DO CR LOOP \ to avoid erasing any line of source, create 42-1 empty lines
543 ESC [H \ then cursor home
544 ESC [7m \ Turn reverse video on
545 $0D EMIT ." FastForth V" \ title line in reverse video
547 0 <# # 'BS' HOLD # '.' HOLD #S #> TYPE
549 HERE \ HERE - MAIN_ORG = bytes code
550 DEVICEID @ \ value kept in TLV area
552 \ device_ID OF ." xxxx," $MAIN_ORG ENDOF \ <-- add here your device
553 $8102 OF ." 5738," $C200 ENDOF
554 $8103 OF ." 5739," $C200 ENDOF
555 $8160 OF ." 5948," $4400 ENDOF
556 $8169 OF ." 5969," $4400 ENDOF
557 $825D OF ." 5972," $4400 ENDOF
558 $81A8 OF ." 6989," $4400 ENDOF
559 $810D OF ." 5986," $4400 ENDOF
560 $81F0 OF ." 4133," $C400 ENDOF
561 $8240 OF ." 2433," $C400 ENDOF
562 $82A1 OF ." 5994," $4000 ENDOF
563 $82A6 OF ." 5962," $4000 ENDOF
564 $830C OF ." 2355," $8000 ENDOF
565 $830D OF ." 2353," $C000 ENDOF
566 $831E OF ." 2155," $8000 ENDOF
567 $831D OF ." 2153," $C000 ENDOF
568 $832A OF ." 2476," $8000 ENDOF
569 $832B OF ." 2475," $8000 ENDOF
570 $833C OF ." 2633," $C400 ENDOF
571 $833D OF ." 2533," $C400 ENDOF
572 ABORT" xxxx <-- unrecognized device!"
573 ENDCASE \ -- HERE MAIN_ORG
574 ['] ['] DUP @ $1284 = \ DOCOL = CALL rDOCOL opcode
575 IF ." DTC=1," DROP \ [CFA] = CALL rDOCOL
577 IF ." DTC=2," \ [CFA] = PUSH IP, [CFA+2] = CALL rDOCOL
578 ELSE ." DTC=3," \ [CFA] = PUSH IP, [CFA+2] = MOV PC,IP
582 THREADS @ U. 'BS' EMIT ." -Entry word sets, " \ number of Entry word sets,
583 FREQ_KHZ @ 0 1000 UM/MOD U. \ frequency,
584 ?DUP IF 'BS' EMIT ',' EMIT U. \ if remainder
585 THEN ." MHz, " \ MCLK
586 - U. ." bytes" \ HERE - MAIN_ORG = number of bytes code,
587 ESC [0m \ Turn off character attributes
589 ." /COUNTED-STRING = 255" CR
592 ." ADDRESS-UNIT-BITS = 16" CR
593 ." FLOORED = true" CR
594 ." MAX-CHAR = 255" CR
597 ." MAX-D = 2147483647" CR
598 ." MAX-UD = 4294967295" CR
599 ." STACK-CELLS = 48" CR
600 ." RETURN-STACK-CELLS= 48" CR
601 ." WoRdS aRe CaSe-InSeNsItIvE" CR
603 ESC [7m ." KERNEL SPECS" ESC [0m \ subtitle in reverse video
606 DUP 0< IF ." 32.768kHz XTAL" CR THEN
607 2* DUP 0< IF ." (RTS/CTS) UART TERMINAL" CR 2*
609 0< IF ." (RTS) UART TERMINAL" CR
612 2* DUP 0< IF ." (XON/XOFF) UART TERMINAL" CR
613 ELSE ." I2C_Master TERMINAL" CR
615 2* DUP 0< IF ." Half-Duplex TERMINAL" CR THEN
616 2* DUP 0< IF ." Q15.16 input" CR THEN
617 2* DUP 0< IF ." DOUBLE input" CR THEN
618 2* DUP 0< IF ." MSP430_X assembler" CR 2* 2*
620 0< IF ." MSP430 Assembler"
621 2* DUP 0< IF ." with 20bits address" THEN
626 2* 2* 2* 2* 2* \ 5 free flags
627 2* 0< IF \ true if COND. COMPILATION
628 [DEFINED] DEFER [IF] ." DEFER word set" CR [THEN]
629 [DEFINED] ALSO [IF] ." VOCABULARY word set" CR [THEN]
630 [DEFINED] BOOT [IF] ." bootloader" CR [THEN]
631 [DEFINED] READ" [IF] ." SD_CARD Read/Write" CR [THEN]
632 [DEFINED] LOAD" [IF] ." SD_CARD Loader" CR [THEN]
634 ESC [7m ." OPTIONS" ESC [0m \ subtitle in reverse video
636 [DEFINED] {CORE_ANS} [IF] ." ANS94 core" CR [THEN]
637 [DEFINED] {DOUBLE} [IF] ." DOUBLE word set" CR [THEN]
638 [DEFINED] {TOOLS} [IF] ." UTILITY" CR [THEN]
639 [DEFINED] {FIXPOINT} [IF] ." Q15.16 ADD SUB MUL DIV" CR [THEN]
640 [DEFINED] {CORDIC} [IF] ." CORDIC engine" CR [THEN]
641 [DEFINED] {SD_TOOLS} [IF] ." SD_TOOLS" CR [THEN]
642 [DEFINED] {RTC} [IF] ." RTC utility" CR [THEN]
643 [DEFINED] {UARTI2CS} [IF] ." UART to I2C_FastForth bridge" CR [THEN]
647 ESC [7m ." ASSEMBLER word set" ESC [0m \ subtitle in reverse video
648 ALSO ASSEMBLER WORDS PREVIOUS \ type ASSEMBLER word set
653 ESC [7m ." FORTH word set" ESC [0m \ subtitle in reverse video
654 WORDS \ type FORTH word set
657 MOV #WARM+4,PC \ type count of bytes free without re-executing INI_APP
660 SPECS \ here FastForth displays a (volatile) message with some informations