
CODE ABORT_CORE_ANS
SUB #2,R15
MOV R14,0(R15)
MOV &$180E,R14
SUB #308,R14
COLON
$0D EMIT
ABORT" FastForth V3.8 please!"
PWR_STATE
;

ABORT_CORE_ANS

; ---------------------------------
; CORE_ANS.4th for MSP_EXP430FR5994
; ---------------------------------
; words complement to pass CORETEST.4TH

[DEFINED] {CORE_ANS} [IF]  {CORE_ANS} [THEN]

[UNDEFINED] {CORE_ANS} [IF]

MARKER {CORE_ANS}

[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] 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] EXIT [IF]
CODE EXIT
MOV @R1+,R13
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] DEPTH [IF]
CODE DEPTH
MOV R14,-2(R15)
MOV #$1C80,R14
SUB R15,R14
RRA R14
SUB #2,R15
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] DROP [IF]
CODE DROP
MOV @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] NIP [IF]
CODE NIP
ADD #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] @ [IF]
CODE @
MOV @R14,R14
MOV @R13+,R0
ENDCODE
[THEN]

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

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

[UNDEFINED] C! [IF]
CODE C!
MOV.B @R15+,0(R14)
ADD #1,R15
MOV @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] C, [IF]
CODE C,
MOV &$1DC6,R10
MOV.B R14,0(R10)
ADD #1,&$1DC6
MOV @R15+,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]
CODE <
        SUB @R15+,R14
        S< ?GOTO FW1
        0<> IF
BW1         MOV #-1,R14
        THEN
        MOV @R13+,R0
ENDCODE

CODE >
        SUB @R15+,R14
        S< ?GOTO BW1
FW1     AND #0,R14
        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

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

: WHILE
POSTPONE IF SWAP
; IMMEDIATE

: 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] J [IF]
CODE J
SUB #2,R15      
MOV R14,0(R15)
MOV 4(R1),R14
SUB 6(R1),R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] UNLOOP [IF]
CODE UNLOOP
ADD #4,R1
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] LEAVE [IF]
CODE LEAVE
MOV &$1DC6,R10
MOV #UNLOOP,0(R10)
MOV #$403A,2(R10)
ADD #6,&$1DC6
ADD #2,&$1C00
ADD #4,R10
MOV &$1C00,R9
MOV R10,0(R9)
MOV @R13+,R0
ENDCODE IMMEDIATE
[THEN]

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

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

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

[UNDEFINED] S>D [IF]
: S>D
    DUP 0<
;
[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] 1+ [IF]
CODE 1+
ADD #1,R14
MOV @R13+,R0
ENDCODE
[THEN]

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

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

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

[UNDEFINED] ABS [IF]
CODE ABS
CMP #0,R14
0>= IF
    MOV @R13+,R0
THEN
MOV #NEGATE,R0
ENDCODE
[THEN]

[UNDEFINED] LSHIFT [IF]
CODE LSHIFT
            MOV @R15+,R10
            AND #$1F,R14
0<> IF
    BEGIN   ADD R10,R10
            SUB #1,R14
    0= UNTIL
THEN        MOV R10,R14
            MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] RSHIFT [IF]
CODE RSHIFT
            MOV @R15+,R10
            AND #$1F,R14
0<> IF
    BEGIN   BIC #1,R2
            RRC R10
            SUB #1,R14
    0= UNTIL
THEN        MOV R10,R14
            MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] MAX [IF]
CODE MAX
    CMP @R15,R14
    S<  ?GOTO FW1
BW1 ADD #2,R15
    MOV @R13+,R0
ENDCODE

CODE MIN
    CMP @R15,R14
    S< ?GOTO BW1
FW1 MOV @R15+,R14
    MOV @R13+,R0
ENDCODE
[THEN]

[THEN]

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

[UNDEFINED] 2/ [IF]
CODE 2/
RRA R14
MOV @R13+,R0
ENDCODE
[THEN]

$1A00 4 + @ $81F3 U<
$81EF $1A00 4 + @ U< 
= [IF]   ; MSP430FR2xxx|MSP430FR4xxx subfamilies without hardware_MPY

    [UNDEFINED] M* [IF]
    


    CODE M*
    MOV @R15,R12
    CMP #0,R12
    S< IF
        XOR #-1,0(R15)
        ADD #1,0(R15)
    THEN
    XOR R14,R12
    CMP #0,R14
    S< IF
        XOR #-1,R14
        ADD #1,R14
    THEN
    PUSHM #2,R13
    LO2HI
    UM*       
    HI2LO
    POPM #2,R13
    CMP #0,R12
    S< IF
        XOR #-1,0(R15)
        XOR #-1,R14
        ADD #1,0(R15)
        ADDC #0,R14
    THEN
    MOV @R13+,R0
    ENDCODE
    [THEN]

[ELSE]  ; MSP430FRxxxx with hardware_MPY

[UNDEFINED] UM* [IF]
CODE UM*
    MOV @R15,&$4C0
BW1 MOV R14,&$4C8
    MOV &$4E4,0(R15)
    MOV &$4E6,R14
    MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] M* [IF]
CODE M*
    MOV @R15,&$4C2
    GOTO BW1
ENDCODE
[THEN]

[THEN]

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

[UNDEFINED] SM/REM [IF]
CODE SM/REM
MOV R14,R12
MOV @R15,R11
CMP #0,R14
S< IF
    XOR #-1,R14
    ADD #1,R14
THEN
CMP #0,0(R15)
S< IF
    XOR #-1,2(R15)
    XOR #-1,0(R15)
    ADD #1,2(R15)
    ADDC #0,0(R15)
THEN
PUSHM #3,R13
LO2HI
    UM/MOD
HI2LO
POPM #3,R13
CMP #0,R11
S< IF
    XOR #-1,0(R15)
    ADD #1,0(R15)
THEN
XOR R12,R11
CMP #0,R11
S< IF
    XOR #-1,R14
    ADD #1,R14
THEN
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] FM/MOD [IF]
: FM/MOD
SM/REM
HI2LO
CMP #0,0(R15)
0<> IF
    CMP #1,R14
    S< IF
      ADD R12,0(R15)
      SUB #1,R14
    THEN
THEN
MOV @R1+,R13
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] * [IF]
: *
M* DROP
;
[THEN]

[UNDEFINED] /MOD [IF]
: /MOD
>R DUP 0< R> FM/MOD
;
[THEN]

[UNDEFINED] / [IF]
: /
>R DUP 0< R> FM/MOD NIP
;
[THEN]

[UNDEFINED] MOD [IF]
: MOD
>R DUP 0< R> FM/MOD DROP
;
[THEN]

[UNDEFINED] */MOD [IF]
: */MOD
>R M* R> FM/MOD
;
[THEN]

[UNDEFINED] */ [IF]
: */
>R M* R> FM/MOD NIP
;
[THEN]

[UNDEFINED] OVER [IF]
CODE OVER
MOV R14,-2(R15)
MOV @R15,R14
SUB #2,R15
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@
SUB #2,R15
MOV R14,0(R15)
MOV @R1,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] TUCK [IF]
: TUCK SWAP OVER ;
[THEN]

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

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

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

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

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

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


[UNDEFINED] ALIGNED [IF]
CODE ALIGNED
BIT #1,R14
ADDC #0,R14
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] ALIGN [IF]
CODE ALIGN
BIT #1,&$1DC6
ADDC #0,&$1DC6
MOV @R13+,R0
ENDCODE
[THEN]


[UNDEFINED] CHARS [IF]
CODE CHARS
MOV @R13+,R0
ENDCODE
[THEN]

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

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

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


[UNDEFINED] CHAR [IF]
: CHAR
    $20 WORD 1+ C@
;
[THEN]

[UNDEFINED] [CHAR] [IF]
: [CHAR]
    CHAR POSTPONE LITERAL
; IMMEDIATE
[THEN]

[UNDEFINED] +! [IF]
CODE +!
ADD @R15+,0(R14)
MOV @R15+,R14
MOV @R13+,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] FILL [IF]
CODE FILL
MOV @R15+,R9
MOV @R15+,R10
CMP #0,R9
0<> IF
    BEGIN
        MOV.B R14,0(R10)
        ADD #1,R10
        SUB #1,R9
    0= UNTIL
THEN
MOV @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

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


[UNDEFINED] HEX [IF]
CODE HEX
MOV #$10,&$1DDC
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] DECIMAL [IF]
CODE DECIMAL
MOV #$0A,&$1DDC
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] ( [IF]
: ( 
')' WORD DROP
; IMMEDIATE
[THEN]

[UNDEFINED] .( [IF]
CODE .(
MOV #0,&$1DB4
COLON
')' WORD
COUNT TYPE
$20 $1DB4 !
; IMMEDIATE
[THEN]

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

[UNDEFINED] EXECUTE [IF]
CODE EXECUTE
PUSH R14
MOV @R15+,R14
MOV @R1+,R0
ENDCODE
[THEN]

[UNDEFINED] EVALUATE [IF]
CODE EVALUATE
MOV #$1DC0,R9
MOV @R9+,R12
MOV @R9+,R11
MOV @R9+,R10
PUSHM #4,R13
LO2HI
INTERPRET
HI2LO
MOV @R1+,&$1DC4
MOV @R1+,&$1DC2
MOV @R1+,&$1DC0
MOV @R1+,R13 
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] RECURSE [IF]
CODE RECURSE
MOV &$1DC6,R9
MOV &$1DBA,0(R9)
ADD #2,&$1DC6
MOV @R13+,R0
ENDCODE IMMEDIATE
[THEN]

[UNDEFINED] SOURCE [IF]
CODE SOURCE
SUB #4,R15
MOV R14,2(R15)
MOV &$1DC0,R14
MOV &$1DC2,0(R15)
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] DOES> [IF]
CODE DOES> 
MOV &$1DBA,R10
MOV #$1285,0(R10)
MOV R13,2(R10)
MOV @R1+,R13
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] VARIABLE [IF]
: VARIABLE 
CREATE
HI2LO
MOV #$1287,-4(R10)
MOV @R1+,R13
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] CONSTANT [IF]
: CONSTANT 
CREATE
HI2LO
MOV R14,-2(R10)
MOV @R15+,R14
MOV @R1+,R13
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] STATE [IF]
$1DBE CONSTANT STATE
[THEN]

[UNDEFINED] BASE [IF]
$1DDC CONSTANT BASE
[THEN]

[UNDEFINED] >IN [IF]
$1DC4 CONSTANT >IN
[THEN]

[UNDEFINED] PAD [IF]
$1CE4 CONSTANT PAD
[THEN]

[UNDEFINED] BL [IF]
$20 CONSTANT BL
[THEN]

[UNDEFINED] SPACE [IF]
: SPACE
$20 EMIT ;
[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] TO [IF]
CODE TO
BIS #$200,R2
MOV @R13+,R0
ENDCODE
[THEN]

[UNDEFINED] VALUE [IF]
: VALUE
CREATE ,
DOES> 
HI2LO
MOV @R1+,R13
BIT #$200,R2
0= IF
    MOV @R14,R14
    MOV @R13+,R0
THEN 
BIC #$200,R2
MOV @R15+,0(R14)
MOV @R15+,R14
MOV @R13+,R0
ENDCODE
[THEN]

RST_HERE

[THEN]

ECHO
; CORE_ANS.4th for MSP_EXP430FR5994 is loaded
