
; ---------------------------------
; FF_SPECS.4th for MSP_EXP430FR5994
; ---------------------------------

CODE ABORT_FF_SPECS
SUB #2,R15
MOV R14,0(R15)
MOV &$180E,R14
SUB #307,R14
COLON
$0D EMIT
ABORT" FastForth version = 3.7 please!"
PWR_STATE
;

ABORT_FF_SPECS

[UNDEFINED] AND [IF]
CODE AND
AND @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] DUP [IF]
CODE DUP
BW1 SUB #2,R15
    MOV R14,0(R15)
    MOV @R13+,R0
ENDCODE

CODE ?DUP
CMP #0,R14
0<> ?GOTO BW1
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] OVER [IF]
CODE OVER
MOV R14,-2(R15)
MOV @R15,R14
SUB #2,R15
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] DROP [IF]
CODE DROP
MOV @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] SWAP [IF]
CODE SWAP
MOV @R15,R10
MOV R14,0(R15)
MOV R10,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] ROT [IF]
CODE ROT
MOV @R15,R10
MOV R14,0(R15)
MOV 2(R15),R14
MOV R10,2(R15)
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] >R [IF]
CODE >R
PUSH R14
MOV @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] R> [IF]
CODE R>
SUB #2,R15
MOV R14,0(R15)
MOV @R1+,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] 0= [IF]
CODE 0=
SUB #1,R14
SUBC R14,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] 0< [IF]
CODE 0<
ADD R14,R14
SUBC R14,R14
XOR #-1,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] = [IF]
CODE =
SUB @R15+,R14
0<> IF
    AND #0,R14
    MOV @R13+,R0
THEN
XOR #-1,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] U< [IF]
CODE U<
SUB @R15+,R14
0<> IF
    MOV #-1,R14
    U< IF
        AND #0,R14
    THEN
THEN
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] IF [IF]
CODE IF
SUB #2,R15
MOV R14,0(R15)
MOV &$1DC6,R14
ADD #4,&$1DC6
MOV #$4034,0(R14)
ADD #2,R14
MOV @R13+,R0
ENDCODE IMMEDIATE

CODE THEN
MOV &$1DC6,0(R14)
MOV @R15+,R14
MOV @R13+,R0
ENDCODE IMMEDIATE
[THEN]

[UNDEFINED] ELSE [IF]
CODE ELSE
ADD #4,&$1DC6
MOV &$1DC6,R10
MOV #$403A,-4(R10)
MOV R10,0(R14)
SUB #2,R10
MOV R10,R14
MOV @R13+,R0
ENDCODE IMMEDIATE
[THEN]

[UNDEFINED] BEGIN [IF]
CODE BEGIN
    MOV #$4028,R0
ENDCODE IMMEDIATE
[THEN]

[UNDEFINED] UNTIL [IF]
CODE UNTIL
    MOV #$4034,R9
BW1 ADD #4,&$1DC6
    MOV &$1DC6,R10
    MOV R9,-4(R10)
    MOV R14,-2(R10)
    MOV @R15+,R14
    MOV @R13+,R0
ENDCODE IMMEDIATE

CODE AGAIN
MOV #$403A,R9
GOTO BW1
ENDCODE IMMEDIATE
[THEN]

[UNDEFINED] WHILE [IF]
: WHILE
POSTPONE IF SWAP
; IMMEDIATE
[THEN]

[UNDEFINED] REPEAT [IF]
: REPEAT
POSTPONE AGAIN POSTPONE THEN
; IMMEDIATE
[THEN]

[UNDEFINED] DO [IF]
CODE DO
SUB #2,R15
MOV R14,0(R15)
ADD #2,&$1DC6
MOV &$1DC6,R14
MOV #$403E,-2(R14)
ADD #2,&$1C00
MOV &$1C00,R10
MOV #0,0(R10)
MOV @R13+,R0
ENDCODE IMMEDIATE

CODE LOOP
    MOV #$4060,R9
BW1 ADD #4,&$1DC6
    MOV &$1DC6,R10
    MOV R9,-4(R10)
    MOV R14,-2(R10)
BEGIN
    MOV &$1C00,R14
    SUB #2,&$1C00
    MOV @R14,R14
    CMP #0,R14
0<> WHILE
    MOV R10,0(R14)
REPEAT
    MOV @R15+,R14
    MOV @R13+,R0
ENDCODE IMMEDIATE

CODE +LOOP
MOV #$404E,R9
GOTO BW1
ENDCODE IMMEDIATE
[THEN]

[UNDEFINED] I [IF]
CODE I
SUB #2,R15
MOV R14,0(R15)
MOV @R1,R14
SUB 2(R1),R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] HERE [IF]
CODE HERE
MOV #$4028,R0
ENDCODE
[THEN]

[UNDEFINED] C@ [IF]
CODE C@
MOV.B @R14,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] SPACES [IF]
CODE SPACES
CMP #0,R14
0<> IF
    PUSH R13
    BEGIN
        LO2HI
        $20 EMIT
        HI2LO
        SUB #2,R13 
        SUB #1,R14
    0= UNTIL
    MOV @R1+,R13
THEN
MOV @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] 1+ [IF]
CODE 1+
ADD #1,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] + [IF]
CODE +
ADD @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] - [IF]
CODE -
SUB @R15+,R14
XOR #-1,R14
ADD #1,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] 2* [IF]
CODE 2*
ADD R14,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] UM/MOD [IF]
CODE UM/MOD
    PUSH #DROP
    MOV #$4066,R0
ENDCODE
[THEN]

[UNDEFINED] MOVE [IF]
CODE MOVE
MOV R14,R10
MOV @R15+,R8
MOV @R15+,R9
MOV @R15+,R14
CMP #0,R10
0<> IF
    CMP R9,R8
    0<> IF
        U< IF
            BEGIN
                MOV.B @R9+,0(R8)
                ADD #1,R8
                SUB #1,R10
            0= UNTIL
            MOV @R13+,R0
        THEN
        ADD R10,R8
        ADD R10,R9
        BEGIN
            SUB #1,R9
            SUB #1,R8
            MOV.B @R9,0(R8)
            SUB #1,R10
        0= UNTIL
    THEN
THEN
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] WORDS [IF]
: WORDS
CR 
$1DCA @ $1CE4
$1810 @ 2*
MOVE
BEGIN
    0 DUP
    $1810 @ 2* 0
        DO
        DUP I $1CE4 + @
            U< IF
                DROP DROP
                I DUP $1CE4 + @
            THEN
        2 +LOOP
    ?DUP
WHILE
    DUP
    2 - @
    ROT
    $1CE4 +
    !
    DUP
    COUNT $7F AND
    TYPE
    C@ $0F AND
    $10 SWAP - SPACES
REPEAT
DROP
;
[THEN]

[UNDEFINED] CASE [IF]
: CASE 0 ; IMMEDIATE

: OF
1+	
>R	
POSTPONE OVER POSTPONE =
POSTPONE IF	
POSTPONE DROP	
R>	
; IMMEDIATE 

: ENDOF
>R	
POSTPONE ELSE 
R>	
; IMMEDIATE 

: ENDCASE
POSTPONE DROP
0 DO 
    POSTPONE THEN 
LOOP 
; IMMEDIATE 
[THEN]

[UNDEFINED] S_ [IF]
CODE S_
MOV #0,&$1DB4
COLON
$4014 ,
$20 WORD
HI2LO
MOV.B @R14,R14
ADD #1,R14
BIT #1,R14
ADDC R14,&$1DC6
MOV @R15+,R14
MOV @R1+,R13
MOV #$20,&$1DB4
MOV @R13+,R0
ENDCODE IMMEDIATE
[THEN]

[UNDEFINED] ESC [IF]
CODE ESC
CMP #0,&$1DBE
0= IF MOV @R13+,R0
THEN
COLON          
$1B
POSTPONE LITERAL
POSTPONE EMIT
POSTPONE S_
POSTPONE TYPE
; IMMEDIATE
[THEN]

: SPECS
PWR_STATE
ECHO
ESC [8;40;80t
39 0 DO CR LOOP
ESC [H
ESC [7m
$0D EMIT ." FastForth V"
$180E @         
0 <# # $08 HOLD # '.' HOLD #S #> TYPE
."  for MSP430FR"
HERE
$1A04 @
CASE
    $8102   OF  ." 5738,"   $C200   ENDOF 
    $8103   OF  ." 5739,"   $C200   ENDOF
    $8160   OF  ." 5948,"   $4400   ENDOF
    $8169   OF  ." 5969,"   $4400   ENDOF
    $825D   OF  ." 5972,"   $4400   ENDOF
    $81A8   OF  ." 6989,"   $4400   ENDOF
    $810D   OF  ." 5986,"   $4400   ENDOF
    $81F0   OF  ." 4133,"   $C400   ENDOF
    $8240   OF  ." 2433,"   $C400   ENDOF
    $82A1   OF  ." 5994,"   $4000   ENDOF
    $82A6   OF  ." 5962,"   $4000   ENDOF
    $830C   OF  ." 2355,"   $8000   ENDOF
    $830D   OF  ." 2353,"   $C000   ENDOF
    $831E   OF  ." 2155,"   $8000   ENDOF
    $831D   OF  ." 2153,"   $C000   ENDOF
    $832A   OF  ." 2476,"   $8000   ENDOF
    $832B   OF  ." 2475,"   $8000   ENDOF
    $833C   OF  ." 2633,"   $C400   ENDOF
    $833D   OF  ." 2533,"   $C400   ENDOF
    ABORT" xxxx <-- unrecognized device!"
ENDCASE
['] ['] DUP @ $1284 =
IF ."  DTC=1," DROP
ELSE 2 + @ $1284 =
    IF ."  DTC=2,"
    ELSE ."  DTC=3,"
    THEN
THEN
$20 EMIT 
$1810 @ U. $08 EMIT ." -Entry word sets, "
$1800 @ 0 1000 UM/MOD U.
?DUP IF $08 EMIT ',' EMIT U.
THEN ." MHz, "
- U. ." bytes"
ESC [0m
CR
." /COUNTED-STRING   = 255" CR 
." /HOLD             = 34" CR
." /PAD              = 84" CR
." ADDRESS-UNIT-BITS = 16" CR
." FLOORED           = true" CR
." MAX-CHAR          = 255" CR
." MAX-N             = 32767" CR
." MAX-U             = 65535" CR
." MAX-D             = 2147483647" CR
." MAX-UD            = 4294967295" CR
." STACK-CELLS       = 48" CR
." RETURN-STACK-CELLS= 48" CR
." WoRdS aRe CaSe-InSeNsItIvE" CR
CR 
ESC [7m ." KERNEL SPECS" ESC [0m
CR
$1812 @
    DUP 0< IF ." 32.768kHz XTAL" CR THEN
2*  DUP 0< IF ." (4/2) UART TERMINAL" CR 2*
        ELSE  2* DUP
            0< IF ." (RTS) UART TERMINAL" CR
            THEN
        THEN
2*  DUP 0< IF ." (XON/XOFF) UART TERMINAL" CR
        ELSE  ." I2C_Master TERMINAL" CR
        THEN
2*  DUP 0< IF ." Half-Duplex TERMINAL" CR THEN
2*  DUP 0< IF ." Q15.16 input" CR THEN
2*  DUP 0< IF ." DOUBLE input" CR THEN
2*  DUP 0< IF ." MSP430_X assembler" CR 2* 2* 
        ELSE 2*  DUP
            0< IF ." MSP430 Assembler"
                2*  DUP 0< IF ."  with 20bits address" THEN
                CR
            ELSE 2*
            THEN
        THEN
2* 2* 2* 2* 2*
2* 0< IF
    [DEFINED] DEFER [IF] ." DEFER word set" CR [THEN]
    [DEFINED] ALSO  [IF] ." VOCABULARY word set" CR [THEN]
    [DEFINED] BOOT  [IF] ." bootloader" CR [THEN]
    [DEFINED] READ" [IF] ." SD_CARD Read/Write" CR [THEN]
    [DEFINED] LOAD" [IF] ." SD_CARD Loader" CR [THEN]
    CR 
    ESC [7m ." OPTIONS" ESC [0m
    CR
    [DEFINED] {CORE_ANS}  [IF] ." ANS94 core" CR [THEN]
    [DEFINED] {DOUBLE}    [IF] ." DOUBLE word set" CR [THEN]
    [DEFINED] {TOOLS}     [IF] ." UTILITY" CR [THEN]
    [DEFINED] {FIXPOINT}  [IF] ." Q15.16 ADD SUB MUL DIV" CR [THEN]
    [DEFINED] {CORDIC}    [IF] ." CORDIC engine" CR [THEN]
    [DEFINED] {SD_TOOLS}  [IF] ." SD_TOOLS" CR [THEN]
    [DEFINED] {RTC}       [IF] ." RTC utility" CR [THEN]
    [DEFINED] {UARTI2CS}  [IF] ." UART to I2C_FastForth bridge" CR [THEN]
    [DEFINED] ALSO
    [IF] 
        CR 
        ESC [7m ." ASSEMBLER word set" ESC [0m
        ALSO ASSEMBLER WORDS PREVIOUS
        CR
    [THEN]
THEN
CR
ESC [7m ." FORTH word set"  ESC [0m
WORDS
CR
HI2LO
MOV #WARM+4,R0
ENDCODE

SPECS
