.word voclink
voclink .set $-2
- FORTHWORDIMM "HI2LO" ; immediate, switch to low level, add ASSEMBLER context, set interpretation state
+ FORTHWORDIMM "HI2LO" ; immediate, switch to low level, add ASSEMBLER context, set interpretation state
mDOCOL
- .word HERE,CELLPLUS,COMMA
+HI2LO .word HERE,CELLPLUS,COMMA
.word LEFTBRACKET
HI2LONEXT .word ALSO,ASSEMBLER
.word EXIT
- FORTHWORD "CODE" ;
-ASMCODE CALL #HEADER ; same as ":" ...
- SUB #4,&DDP ; ...but compile nothing
+; FORTHWORDIMM "SEMIC" ; same as HI2LO, plus restore IP; counterpart of COLON
+; mDOCOL
+; .word HI2LO
+; .word LIT,413Dh,COMMA ; compile MOV @RSP+,IP
+; .word EXIT
+
+ FORTHWORD "CODE" ; a CODE word must be finished with ENDCODE
+ASMCODE CALL #HEADER ;
+ SUB #4,&DDP ;
mDOCOL
.word SAVE_PSP
.word BRAN,HI2LONEXT
+ asmword "ENDCODE" ; restore previous context and test PSP balancing
+ENDCODE mDOCOL
+ .word PREVIOUS,QREVEAL
+ .word EXIT
+
FORTHWORD "ASM" ; used to define an assembler word which is not executable by FORTH interpreter
; i.e. typically an assembler word called by CALL and ended by RET
- ; ASM word is only accessible in ASSEMBLER CONTEXT
+ ; ASM words are only usable in another ASSEMBLER words
+ ; an ASM word must be finished with ENDASM
MOV &CURRENT,&ASM_CURRENT
MOV #ASSEMBLER_BODY,&CURRENT
JMP ASMCODE
- asmword "ENDCODE" ; restore previous context and test PSP balancing
-ENDCODE mDOCOL
- .word PREVIOUS,QREVEAL
- .word EXIT
-
- asmword "ENDASM" ; end of ASM word
+ asmword "ENDASM" ; end of an ASM word
MOV &ASM_CURRENT,&CURRENT
JMP ENDCODE
asmword "COLON" ; compile DOCOL, remove ASSEMBLER from CONTEXT, switch to compilation state
MOV &DDP,W
-
+
.SWITCH DTC
.CASE 1
MOV #DOCOL1,0(W) ; compile CALL xDOCOL
; Search ARG of <sep>"xxxx(REG)" ; <== PARAM210
SearchARG ASMtoFORTH ; -- separator search word first
.word WORDD,FIND ; -- c-addr
- .word ZEROEQUAL
- .word QBRAN,SearchARGW ; -- c-addr if found
- .word QNUMBER ;
+; .word ZEROEQUAL
+; .word QBRAN,SearchARGW ; -- c-addr if found
+ .word QZBRAN,SearchARGW ; -- c-addr if found
+ .word QNUMBER ;
.word QBRAN,NotFound ; -- c-addr
.word AsmSrchEnd ; -- value end if number found
SearchARGW FORTHtoASM ; -- xt
MOV @RSP+,PC ; ret
QDOCON CMP #DOCON,X
JNZ QDODOES
- MOV 2(TOS),TOS ; remplace CFA by [PFA] for CONSTANT and CREATE words
+ MOV 2(TOS),TOS ; remplace CFA by [PFA] for CONSTANT (and CREATEd) words
MOV @RSP+,PC ; ret
QDODOES CMP #DODOES,X
JNZ AsmSrchEnd
ADD #4,TOS ; leave BODY for DOES words (but don't execute !)
AsmSrchEnd RET ;
-
+
; ----------------------------------------------------------------------
; DTCforthMSP430FR5xxx ASSEMBLER : search REG
; ----------------------------------------------------------------------
SearchREG PUSH &TOIN ; -- separator save >IN
ADD #1,&TOIN ; skip "R"
ASMtoFORTH ; search xx of Rxx
- .word WORDD,QNUMBER ;
+ .word WORDD,QNUMBER ;
.word QBRAN,notREG ; -- xxxx if number found
FORTHtoASM ; -- c-addr if number not found
ADD #2,RSP ; remove >IN
MOV @RSP+,&TOIN ; -- c-addr restore >IN
BIS #Z,SR ; Z=1 ==> not found
MOV @RSP+,PC ; -- c_addr
-
+
; ----------------------------------------------------------------------
; DTCforthMSP430FR5xxx ASSEMBLER : INTERPRET FIRST OPERAND
; ----------------------------------------------------------------------
; case of all others "#xxxx"<sep> ; -- xxxx
PARAM1000 MOV #0030h,&ASMTYPE ; -- xxxx add immediate code type : @PC+,
-
+
; case of "&xxxx"<sep> ; <== PARAM110
; case of <sep>"&xxxx" ; <== PARAM20
StoreArg MOV &DDP,X ; -- xxxx
; case of "&xxxx"<sep>
; case of <sep>"&xxxx" ; <== PARAM20
PARAM111 ADD #1,&TOIN ; -- sep skip "&" prefix
- PUSH #StoreArg ; prepare next ret : compile xxxx then ret
+ PUSH #StoreArg ; prepare next ret : compile xxxx then ret
JMP SearchARG ; -- sep abort if not found
; ------------------------------------------
; PARAM2 -- ; parse input buffer until BL and compute this 2th operand
-PARAM2 mDOCOL ;
+PARAM2 mDOCOL ;
.word FBLANK,SKIP ; skip space(s) between "arg1," and "arg2" if any
FORTHtoASM ; -- c-addr search for '&' of "&xxxx
CMP.B #'&',0(TOS) ;
mDOCON
.word 3400h
- asmword "0>=" ; if 0>= assertion ; use only with IF UNTIL WHILE !
+ asmword "0>=" ; if 0>= assertion ; use only with IF UNTIL WHILE !
mDOCON
.word 3000h
;C ELSE @OPCODE1 -- @OPCODE2 branch for IF..ELSE
asmword "ELSE"
ASM_ELSE MOV &DDP,W ; -- W=HERE
- MOV #3C00h,0(W) ; compile unconditionnal branch
+ MOV #3C00h,0(W) ; compile unconditionnal branch
ADD #2,&DDP ; -- DP+2
SUB #2,PSP
MOV W,0(PSP) ; -- dst
.word ASM_UNTIL,EXIT
-; invert FORTH conditionnal branch FORTH_JMP_OPCODE -- LABEL_JMP_OPCODE
+; invert FORTH conditionnal branch FORTH_JMP_OPCODE -- LABEL_JMP_OPCODE
INVJMP BIT #1000h,TOS ; 3xxxh case ?
JNZ INVJMP3xxxh ; yes
INVJMP2xxxh XOR #0400h,TOS ; no: case of JNE/JNZ JEQ/JZ JNC/JLO JC/JHS
INVJMP3800h MOV #3400h,TOS ; not jump if >= --> jump if <
mNEXT
INVJMP3400h MOV #3800h,TOS ; not jump if < --> jump if >=
-INVJMPEND mNEXT
+INVJMPEND mNEXT
;ASM <cond> ?JMP <word> ; OPCODE -- conditionnal branch to a previous definition
MOV @RSP+,IP
MOV TOS,Y
MOV @PSP+,TOS
- MOV @Y,W ; W = [PFA]
+ MOV @Y,W ; W = [PFA]
CMP #0,W ; W = 0 ?
JNZ BACKWUSE
BACKWSET ; --
; backward label 1
asmword "BW1"
- mdodoes
+ mdodoes
.word BACKWARDDOES
CLRBW1 .word 0
; backward label 2
asmword "BW2"
- mdodoes
+ mdodoes
.word BACKWARDDOES
CLRBW2 .word 0
; backward label 3
asmword "BW3"
- mdodoes
+ mdodoes
.word BACKWARDDOES
CLRBW3 .word 0
; forward label 1
asmword "FW1"
- mdodoes
+ mdodoes
.word FORWARDDOES
CLRFW1 .word 0
; forward label 2
asmword "FW2"
- mdodoes
+ mdodoes
.word FORWARDDOES
CLRFW2 .word 0
; forward label 3
asmword "FW3"
- mdodoes
+ mdodoes
.word FORWARDDOES
CLRFW3 .word 0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-