1 \ -*- coding: utf-8 -*-
7 ; displays all FastForth specifications
10 \ TARGET SELECTION : copy your target in (shift+F8) parameter 1:
12 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
13 \ MSP_EXP430FR4133 CHIPSTICK_FR2433 MSP_EXP430FR2433 MSP_EXP430FR2355
17 \ drag and drop this file onto SendSourceFileToTarget.bat
18 \ then select your TARGET when asked.
20 PWR_STATE \ remove volatile words
23 \ https://forth-standard.org/standard/core/AND
24 \ C AND x1 x2 -- x3 logical AND
31 [UNDEFINED] DUP [IF] \ define DUP and DUP?
32 \ https://forth-standard.org/standard/core/DUP
33 \ DUP x -- x x duplicate top of stack
35 BW1 SUB #2,PSP \ 2 push old TOS..
36 MOV TOS,0(PSP) \ 3 ..onto stack
40 \ https://forth-standard.org/standard/core/qDUP
41 \ ?DUP x -- 0 | x x DUP if nonzero
43 CMP #0,TOS \ 2 test for TOS nonzero
50 \ https://forth-standard.org/standard/core/OVER
51 \ OVER x1 x2 -- x1 x2 x1
53 MOV TOS,-2(PSP) \ 3 -- x1 (x2) x2
54 MOV @PSP,TOS \ 2 -- x1 (x2) x1
55 SUB #2,PSP \ 1 -- x1 x2 x1
61 \ https://forth-standard.org/standard/core/DROP
62 \ DROP x -- drop top of stack
70 \ https://forth-standard.org/standard/core/SWAP
71 \ SWAP x1 x2 -- x2 x1 swap top two items
81 \ https://forth-standard.org/standard/core/ROT
82 \ ROT x1 x2 x3 -- x2 x3 x1
84 MOV @PSP,W \ 2 fetch x2
85 MOV TOS,0(PSP) \ 3 store x3
86 MOV 2(PSP),TOS \ 3 fetch x1
87 MOV W,2(PSP) \ 3 store x2
93 \ https://forth-standard.org/standard/core/toR
94 \ >R x -- R: -- x push to return stack
103 \ https://forth-standard.org/standard/core/Rfrom
104 \ R> -- x R: x -- pop from return stack ; CALL #RFROM performs DOVAR
114 \ https://forth-standard.org/standard/core/ZeroEqual
115 \ 0= n/u -- flag return true if TOS=0
117 SUB #1,TOS \ borrow (clear cy) if TOS was 0
118 SUBC TOS,TOS \ TOS=-1 if borrow was set
124 \ https://forth-standard.org/standard/core/Zeroless
125 \ 0< n -- flag true if TOS negative
127 ADD TOS,TOS \ 1 set carry if TOS negative
128 SUBC TOS,TOS \ 1 TOS=-1 if carry was clear
129 XOR #-1,TOS \ 1 TOS=-1 if carry was set
135 \ https://forth-standard.org/standard/core/Equal
136 \ = x1 x2 -- flag test x1=x2
140 AND #0,TOS \ 1 flag Z = 1
148 \ https://forth-standard.org/standard/core/Uless
149 \ U< u1 u2 -- flag test u1<u2, unsigned
152 SUB @PSP+,TOS \ 2 u2-u1
156 AND #0,TOS \ 1 flag Z = 1
163 [UNDEFINED] IF [IF] \ define IF and THEN
164 \ https://forth-standard.org/standard/core/IF
165 \ IF -- IFadr initialize conditional forward branch
169 MOV &DP,TOS \ -- HERE
170 ADD #4,&DP \ compile one word, reserve one word
171 MOV #QFBRAN,0(TOS) \ -- HERE compile QFBRAN
172 ADD #2,TOS \ -- HERE+2=IFadr
176 \ https://forth-standard.org/standard/core/THEN
177 \ THEN IFadr -- resolve forward branch
179 MOV &DP,0(TOS) \ -- IFadr
185 [UNDEFINED] ELSE [IF]
186 \ https://forth-standard.org/standard/core/ELSE
187 \ ELSE IFadr -- ELSEadr resolve forward IF branch, leave ELSEadr on stack
189 ADD #4,&DP \ make room to compile two words
192 MOV W,0(TOS) \ HERE+4 ==> [IFadr]
194 MOV W,TOS \ -- ELSEadr
199 [UNDEFINED] BEGIN [IF] \ define BEGIN UNTIL AGAIN WHILE REPEAT
200 \ https://forth-standard.org/standard/core/BEGIN
201 \ BEGIN -- BEGINadr initialize backward branch
206 \ https://forth-standard.org/standard/core/UNTIL
207 \ UNTIL BEGINadr -- resolve conditional backward branch
210 BW1 ADD #4,&DP \ compile two words
212 MOV X,-4(W) \ compile Bran or QFBRAN at HERE
213 MOV TOS,-2(W) \ compile bakcward adr at HERE+2
218 \ https://forth-standard.org/standard/core/AGAIN
219 \ AGAIN BEGINadr -- resolve uncondionnal backward branch
225 \ https://forth-standard.org/standard/core/WHILE
226 \ WHILE BEGINadr -- WHILEadr BEGINadr
231 \ https://forth-standard.org/standard/core/REPEAT
232 \ REPEAT WHILEadr BEGINadr -- resolve WHILE loop
234 POSTPONE AGAIN POSTPONE THEN
238 [UNDEFINED] DO [IF] \ define DO LOOP +LOOP
239 \ https://forth-standard.org/standard/core/DO
240 \ DO -- DOadr L: -- 0
244 ADD #2,&DP \ make room to compile xdo
245 MOV &DP,TOS \ -- HERE+2
246 MOV #XDO,-2(TOS) \ compile xdo
247 ADD #2,&LEAVEPTR \ -- HERE+2 LEAVEPTR+2
249 MOV #0,0(W) \ -- HERE+2 L-- 0
253 \ https://forth-standard.org/standard/core/LOOP
254 \ LOOP DOadr -- L-- an an-1 .. a1 0
257 BW1 ADD #4,&DP \ make room to compile two words
259 MOV X,-4(W) \ xloop --> HERE
260 MOV TOS,-2(W) \ DOadr --> HERE+2
261 BEGIN \ resolve all "leave" adr
262 MOV &LEAVEPTR,TOS \ -- Adr of top LeaveStack cell
263 SUB #2,&LEAVEPTR \ --
264 MOV @TOS,TOS \ -- first LeaveStack value
265 CMP #0,TOS \ -- = value left by DO ?
267 MOV W,0(TOS) \ move adr after loop as UNLOOP adr
273 \ https://forth-standard.org/standard/core/PlusLOOP
274 \ +LOOP adrs -- L-- an an-1 .. a1 0
277 GOTO BW1 \ goto BW1 LOOP
282 \ https://forth-standard.org/standard/core/I
283 \ I -- n R: sys1 sys2 -- sys1 sys2
284 \ get the innermost loop index
286 SUB #2,PSP \ 1 make room in TOS
288 MOV @RSP,TOS \ 2 index = loopctr - fudge
294 [UNDEFINED] HERE [IF]
301 \ https://forth-standard.org/standard/core/Fetch
302 \ @ c-addr -- char fetch char from memory
310 \ https://forth-standard.org/standard/core/Store
311 \ ! x a-addr -- store cell in memory
320 \ https://forth-standard.org/standard/core/CFetch
321 \ C@ c-addr -- char fetch char from memory
328 [UNDEFINED] SPACES [IF]
329 \ https://forth-standard.org/standard/core/SPACES
330 \ SPACES n -- output n spaces
344 MOV @PSP+,TOS \ -- drop n
350 \ https://forth-standard.org/standard/core/OnePlus
351 \ 1+ n1/u1 -- n2/u2 add 1 to TOS
359 \ https://forth-standard.org/standard/core/Plus
360 \ + n1/u1 n2/u2 -- n3/u3 add n1+n2
368 \ https://forth-standard.org/standard/core/Minus
369 \ - n1/u1 n2/u2 -- n3/u3 n3 = n1-n2
371 SUB @PSP+,TOS \ 2 -- n2-n1 ( = -n3)
373 ADD #1,TOS \ 1 -- n3 = -(n2-n1) = n1-n2
379 \ https://forth-standard.org/standard/core/TwoTimes
380 \ 2* x1 -- x2 arithmetic left shift
387 [UNDEFINED] UM/MOD [IF]
388 \ https://forth-standard.org/standard/core/UMDivMOD
389 \ UM/MOD udlo|udhi u1 -- r q unsigned 32/16->r16 q16
392 MOV #MUSMOD,PC \ execute MUSMOD then return to DROP
396 [UNDEFINED] MOVE [IF]
397 \ https://forth-standard.org/standard/core/MOVE
398 \ MOVE addr1 addr2 u -- smart move
399 \ VERSION FOR 1 ADDRESS UNIT = 1 CHAR
402 MOV @PSP+,Y \ Y = addr2 = dst
403 MOV @PSP+,X \ X = addr1 = src
404 MOV @PSP+,TOS \ pop new TOS
405 CMP #0,W \ count = 0 ?
406 0<> IF \ if 0, already done !
407 CMP X,Y \ Y-X \ dst - src
408 0<> IF \ if dst = src, already done !
409 U< IF \ U< if src > dst
416 THEN \ U>= if dst > src
417 ADD W,Y \ copy W bytes beginning with the end
431 [UNDEFINED] WORDS [IF]
432 \ https://forth-standard.org/standard/tools/WORDS
433 \ list all words of vocabulary first in CONTEXT.
436 CONTEXT @ PAD_ORG \ -- VOC_BODY PAD MOVE all threads of VOC_BODY in PAD_ORG
437 INI_THREAD @ 2* \ -- VOC_BODY PAD THREAD*2
438 MOVE \ -- vocabulary entries are copied in PAD_ORG
440 0 DUP \ -- ptr=0 MAX=0
441 INI_THREAD @ 2* 0 \ -- ptr=0 MAX=0 THREADS*2 0
442 DO \ -- ptr MAX I = PAD_ptr = thread*2
443 DUP I PAD_ORG + @ \ -- ptr MAX MAX NFAx
444 U< IF \ -- ptr MAX if MAX U< NFAx
445 DROP DROP \ -- drop ptr and MAX
446 I DUP PAD_ORG + @ \ -- new_ptr new_MAX
449 ?DUP \ -- ptr MAX MAX | -- ptr 0 (all threads in PAD = 0)
450 WHILE \ -- ptr MAX replace it by its LFA
452 2 - @ \ -- ptr MAX [LFA]
453 ROT \ -- MAX [LFA] ptr
454 PAD_ORG + \ -- MAX [LFA] thread
455 ! \ -- MAX [LFA]=new_NFA updates PAD+ptr
457 COUNT $7F AND \ -- MAX addr count (with suppr. of immediate bit)
459 C@ $0F AND \ -- count_of_chars
460 $10 SWAP - SPACES \ -- complete with spaces modulo 16 chars
463 ; \ all threads in PAD are filled with 0
466 [UNDEFINED] CASE [IF]
467 \ https://forth-standard.org/standard/core/CASE
468 : CASE 0 ; IMMEDIATE \ -- #of-1
470 \ https://forth-standard.org/standard/core/OF
471 : OF \ #of-1 -- orgOF #of
473 >R \ move off the stack in case the control-flow stack is the data stack.
474 POSTPONE OVER POSTPONE = \ copy and test case value
475 POSTPONE IF \ add orig to control flow stack
476 POSTPONE DROP \ discards case value if =
477 R> \ we can bring count back now
480 \ https://forth-standard.org/standard/core/ENDOF
481 : ENDOF \ orgOF #of -- orgENDOF #of
482 >R \ move off the stack in case the control-flow stack is the data stack.
484 R> \ we can bring count back now
487 \ https://forth-standard.org/standard/core/ENDCASE
488 : ENDCASE \ orgENDOF1..orgENDOFn #of --
497 CODE S_ \ Squote alias with blank instead quote separator
498 MOV #0,&CAPS \ turn CAPS OFF
500 XSQUOTE , \ compile run-time code
501 $20 WORD \ -- c-addr (= HERE)
503 MOV.B @TOS,TOS \ -- len compile string
504 ADD #1,TOS \ -- len+1
506 ADDC TOS,&DP \ store aligned DP
508 MOV @RSP+,IP \ pop paired with push COLON
509 MOV #$20,&CAPS \ turn CAPS ON (default state)
517 0= IF MOV @IP+,PC \ interpret time usage disallowed
521 POSTPONE LITERAL \ compile-time code : lit $1B
522 POSTPONE EMIT \ compile-time code : EMIT
523 POSTPONE S_ \ compile-time code : S_ <escape_sequence>
524 POSTPONE TYPE \ compile-time code : TYPE
528 : SPECS \ to see Fast Forth specifications
529 PWR_STATE \ before free bytes computing, remove all created words
532 42 0 DO CR LOOP \ to avoid erasing any line of source, create 42 empty lines
533 ESC [H \ then cursor home
535 ESC [7m \ Turn reverse video on
536 CR ." FastForth V" \ title line in reverse video
538 0 <# # 8 HOLD # 46 HOLD #S #> TYPE
540 HERE \ HERE - MAIN_ORG = bytes code
541 DEVICEID @ \ value kept in TLV area
543 \ device_ID OF ." xxxx," $MAIN_ORG ENDOF \ <-- add here your device
544 $8102 OF ." 5738," $C200 ENDOF
545 $8103 OF ." 5739," $C200 ENDOF
546 $8160 OF ." 5948," $4400 ENDOF
547 $8169 OF ." 5969," $4400 ENDOF
548 $81A8 OF ." 6989," $4400 ENDOF
549 \ $810D OF ." 5986," $4400 ENDOF
551 $81F0 OF ." 4133," $C400 ENDOF
552 $8240 OF ." 2433," $C400 ENDOF
554 $82A1 OF ." 5994," $4000 ENDOF
555 \ $82A6 OF ." 5962," $4000 ENDOF
557 $830C OF ." 2355," $8000 ENDOF
558 \ $830D OF ." 2353," $C000 ENDOF
559 \ $831E OF ." 2155," $8000 ENDOF
560 \ $831D OF ." 2153," $C000 ENDOF
561 $832A OF ." 2476," $8000 ENDOF
562 \ $832B OF ." 2475," $8000 ENDOF
563 \ $833C OF ." 2633," $C400 ENDOF
564 \ $833D OF ." 2533," $C400 ENDOF
565 ABORT" xxxx <-- unrecognized device!"
566 ENDCASE \ -- HERE MAIN_ORG
568 ['] ['] DUP @ $1284 = \ DOCOL = CALL rDOCOL opcode
569 IF ." DTC=1," DROP \ [CFA] = CALL rDOCOL
571 IF ." DTC=2," \ [CFA] = PUSH IP, [CFA+2] = CALL rDOCOL
572 ELSE ." DTC=3," \ [CFA] = PUSH IP, [CFA+2] = MOV PC,IP
576 INI_THREAD @ U. #8 EMIT ." -Entry word sets, " \ number of Entry word sets,
577 FREQ_KHZ @ 0 1000 UM/MOD U. \ frequency,
578 ?DUP IF #8 EMIT #44 EMIT U. \ if remainder
579 THEN ." MHz, " \ MCLK
580 - U. ." bytes" \ HERE - MAIN_ORG = number of bytes code,
581 ESC [0m \ Turn off character attributes
583 ." /COUNTED-STRING = 255" CR
586 ." ADDRESS-UNIT-BITS = 16" CR
587 ." FLOORED = true" CR
588 ." MAX-CHAR = 255" CR
591 ." MAX-D = 2147483647" CR
592 ." MAX-UD = 4294967295" CR
593 ." STACK-CELLS = 48" CR
594 ." RETURN-STACK-CELLS= 48" CR
597 ESC [7m ." KERNEL ADDONS" ESC [0m \ subtitle in reverse video
601 DUP 0< IF ." 32.768kHz XTAL" CR THEN
602 2* DUP 0< IF 2* ." 5 WIRES (RTS/CTS) UART TERMINAL" CR
604 0< IF ." 4 WIRES (RTS) UART TERMINAL" CR
607 2* DUP 0< IF ." 3 WIRES (XON/XOFF) UART TERMINAL" CR
608 ELSE ." I2C SLAVE TERMINAL INPUT" CR
610 2* DUP 0< IF ." HALF-DUPLEX TERMINAL" CR THEN
611 2* DUP 0< IF ." ASM DATA ACCESS BEYOND $FFFF" CR THEN
612 2* DUP 0< IF ." BOOTLOADER" CR THEN
613 2* DUP 0< IF ." SD_CARD READ/WRITE" CR THEN
614 2* DUP 0< IF ." SD_CARD LOADER" CR THEN
615 2* DUP 0< IF ." FIXPOINT INPUT" CR THEN
616 2* DUP 0< IF ." DOUBLE INPUT" CR THEN
617 2* DUP 0< IF ." VOCABULARY SET" CR THEN
618 2* DUP 0< IF ." DEFERRED words" CR THEN
619 2* DUP 0< IF ." EXTENDED ASSEMBLER" CR THEN
620 2* DUP 0< IF ." ASSEMBLER" CR THEN
621 2* DUP 0< IF ." CONDITIONNAL COMPILATION" CR THEN
622 0< IF \ true if CONDCOMP add-on
624 ESC [7m ." OPTIONS" ESC [0m \ subtitle in reverse video
626 [DEFINED] {CORE_ANS} [IF] ." ANS94 CORE COMPLIANT" CR [THEN]
627 [DEFINED] {TOOLS} [IF] ." UTILITY" CR [THEN]
628 [DEFINED] {FIXPOINT} [IF] ." FIXPOINT" CR [THEN]
629 [DEFINED] {CORDIC} [IF] ." CORDIC engine" CR [THEN]
630 [DEFINED] {SD_TOOLS} [IF] ." SD_TOOLS" CR [THEN]
631 [DEFINED] {RTC} [IF] ." RTC utility" CR [THEN]
633 [DEFINED] VOCABULARY [IF]
635 ESC [7m ." ASSEMBLER word set" ESC [0m \ subtitle in reverse video
636 ALSO ASSEMBLER WORDS PREVIOUS \ type ASSEMBLER word set
643 ESC [7m ." FORTH word set" ESC [0m \ subtitle in reverse video
644 WORDS \ type FORTH word set
647 WARM \ type bytes free
650 SPECS \ here FastForth types a (volatile) message with some informations