
; -----------------------------------------------------
; ANS_COMP.4th    words complement to pass CORETEST.4th
; -----------------------------------------------------

PWR_STATE

[UNDEFINED] {ANS_COMP} [IF]

MARKER {ANS_COMP}

[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]

CODE INVERT
XOR #-1,R14
MOV @R13+,R0
ENDCODE

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

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

[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]

CODE 2*
ADD R14,R14
MOV @R13+,R0
ENDCODE

CODE 2/
RRA R14
MOV @R13+,R0
ENDCODE

$1A04 C@ $EF > [IF] ; test tag value MSP430FR413x subfamily without hardware_MPY 

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

[ELSE]              ; MSP430FRxxxx with hardware_MPY

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

CODE M*
    MOV @R15,&$4C2
    GOTO BW1
ENDCODE

[THEN]

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
BW1
BW2
    XOR #-1,R14
    ADD #1,R14
THEN
MOV @R13+,R0
ENDCODE

CODE NEGATE
GOTO BW1 
ENDCODE

CODE ABS
CMP #0,R14
0< ?GOTO BW2
MOV @R13+,R0
ENDCODE

: 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

: *
M* DROP
;

: /MOD
>R DUP 0< R> FM/MOD
;

: /
>R DUP 0< R> FM/MOD NIP
;

: MOD
>R DUP 0< R> FM/MOD DROP
;

: */MOD
>R M* R> FM/MOD
;

: */
>R M* R> FM/MOD NIP
;


: S>D
    DUP 0<
;

CODE 2@
SUB #2,R15
MOV 2(R14),0(R15)
MOV @R14,R14
MOV @R13+,R0
ENDCODE

CODE 2!
MOV @R15+,0(R14)
MOV @R15+,2(R14)
MOV @R15+,R14
MOV @R13+,R0
ENDCODE

CODE 2DUP
SUB #4,R15
MOV R14,2(R15)
MOV 4(R15),0(R15)
MOV @R13+,R0
ENDCODE

CODE 2DROP
ADD #2,R15
MOV @R15+,R14
MOV @R13+,R0
ENDCODE

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

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

CODE ALIGNED
BIT #1,R14
ADDC #0,R14
MOV @R13+,R0
ENDCODE

CODE ALIGN
BIT #1,&$1DC6
ADDC #0,&$1DC6
MOV @R13+,R0
ENDCODE

CODE CHARS
MOV @R13+,R0
ENDCODE

CODE CHAR+
ADD #1,R14
MOV @R13+,R0
ENDCODE

CODE CELLS
ADD R14,R14
MOV @R13+,R0
ENDCODE

CODE CELL+
ADD #2,R14
MOV @R13+,R0
ENDCODE

: CHAR
    BL WORD 1+ C@
;

: [CHAR]
    CHAR lit lit , ,
; IMMEDIATE

CODE +!
ADD @R15+,0(R14)
MOV @R15+,R14
MOV @R13+,R0
ENDCODE

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

CODE HEX
MOV #$10,&BASE
MOV @R13+,R0
ENDCODE

CODE DECIMAL
MOV #$0A,&BASE
MOV @R13+,R0
ENDCODE

: ( 
$29 WORD DROP
; IMMEDIATE

CODE .(
MOV #0,&$1DB4
COLON
$29 WORD
COUNT TYPE
BL $1DB4 !
; IMMEDIATE

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

$1DC4 CONSTANT >IN

[UNDEFINED] PAD [IF]

$1CE4 CONSTANT PAD

[THEN]

[THEN]

RST_HERE

ECHO
