1 \ -*- coding: utf-8 -*-
3 \ FastForth kernel options: MSP430ASSEMBLER, CONDCOMP
4 \ to see FastForth kernel options, download FF_SPECS.f
6 \ TARGET SELECTION ( = the name of \INC\target.pat file without the extension)
7 \ (used by preprocessor GEMA to load the pattern: \inc\TARGET.pat)
8 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
9 \ MSP_EXP430FR4133 CHIPSTICK_FR2433 MSP_EXP430FR2433 MSP_EXP430FR2355
11 \ from scite editor : copy your target selection in (shift+F8) parameter 1:
15 \ drag and drop this file onto SendSourceFileToTarget.bat
16 \ then select your TARGET when asked.
20 \ rDODOES to rEXIT must be saved before use and restored after
21 \ scratch registers Y to S are free for use
22 \ under interrupt, IP is free for use
24 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, rEXIT, rDOVAR, rDOCON, rDODOES
25 \ example : PUSHM #6,IP pushes IP,S,T,W,X,Y registers to return stack
27 \ POPM order : rDODOES, rDOCON, rDOVAR, rEXIT, Y, X, W, T, S, IP,TOS,PSP
28 \ example : POPM #6,IP pulls Y,X,W,T,S,IP registers from return stack
30 \ FORTH conditionnals: unary{ 0= 0< 0> }, binary{ = < > U< }
32 \ ASSEMBLER conditionnal usage with IF UNTIL WHILE S< S>= U< U>= 0= 0<> 0>=
33 \ ASSEMBLER conditionnal usage with ?GOTO S< S>= U< U>= 0= 0<> 0<
39 SUB #307,TOS \ FastForth V3.7
41 $0D EMIT \ return to column 1 without CR
42 ABORT" FastForth version = 3.7 please!"
43 PWR_STATE \ remove ABORT_UARTI2CS before CORE_ANS downloading
48 ; ---------------------------------
50 ; ---------------------------------
52 ; words complement to pass CORETEST.4TH
54 [DEFINED] {CORE_ANS} [IF] {CORE_ANS} [THEN] \ remove it if defined out of kernel
56 [UNDEFINED] {CORE_ANS} [IF] \
61 \ https://forth-standard.org/standard/core/Plus
62 \ + n1/u1 n2/u2 -- n3/u3 add n1+n2
70 \ https://forth-standard.org/standard/core/Minus
71 \ - n1/u1 n2/u2 -- n3/u3 n3 = n1-n2
73 SUB @PSP+,TOS \ 2 -- n2-n1 ( = -n3)
75 ADD #1,TOS \ 1 -- n3 = -(n2-n1) = n1-n2
81 \ https://forth-standard.org/standard/core/DUP
82 \ DUP x -- x x duplicate top of stack
84 BW1 SUB #2,PSP \ 2 push old TOS..
85 MOV TOS,0(PSP) \ 3 ..onto stack
89 \ https://forth-standard.org/standard/core/qDUP
90 \ ?DUP x -- 0 | x x DUP if nonzero
92 CMP #0,TOS \ 2 test for TOS nonzero
99 \ https://forth-standard.org/standard/core/EXIT
100 \ EXIT -- exit a colon definition
102 MOV @RSP+,IP \ 2 pop previous IP (or next PC) from return stack
103 MOV @IP+,PC \ 4 = NEXT
108 [UNDEFINED] DEPTH [IF]
109 \ https://forth-standard.org/standard/core/DEPTH
110 \ DEPTH -- +n number of items on stack, must leave 0 if stack empty
114 SUB PSP,TOS \ PSP-S0--> TOS
115 RRA TOS \ TOS/2 --> TOS
116 SUB #2,PSP \ post decrement stack...
121 [UNDEFINED] SWAP [IF]
122 \ https://forth-standard.org/standard/core/SWAP
123 \ SWAP x1 x2 -- x2 x1 swap top two items
132 [UNDEFINED] DROP [IF]
133 \ https://forth-standard.org/standard/core/DROP
134 \ DROP x -- drop top of stack
142 \ https://forth-standard.org/standard/core/NIP
143 \ NIP x1 x2 -- x2 Drop the first item below the top of stack
151 \ https://forth-standard.org/standard/core/toR
152 \ >R x -- R: -- x push to return stack
161 \ https://forth-standard.org/standard/core/Rfrom
162 \ R> -- x R: x -- pop from return stack ; CALL #RFROM performs DOVAR
172 \ https://forth-standard.org/standard/core/Fetch
173 \ @ c-addr -- char fetch char from memory
181 \ https://forth-standard.org/standard/core/Store
182 \ ! x a-addr -- store cell in memory
191 \ https://forth-standard.org/standard/core/CFetch
192 \ C@ c-addr -- char fetch char from memory
200 \ https://forth-standard.org/standard/core/CStore
201 \ C! char c-addr -- store char in memory
203 MOV.B @PSP+,0(TOS) \ 4
211 \ https://forth-standard.org/standard/core/CComma
212 \ C, char -- append char
223 \ https://forth-standard.org/standard/core/ZeroEqual
224 \ 0= n/u -- flag return true if TOS=0
226 SUB #1,TOS \ borrow (clear cy) if TOS was 0
227 SUBC TOS,TOS \ TOS=-1 if borrow was set
233 \ https://forth-standard.org/standard/core/Zeroless
234 \ 0< n -- flag true if TOS negative
236 ADD TOS,TOS \ 1 set carry if TOS negative
237 SUBC TOS,TOS \ 1 TOS=-1 if carry was clear
238 XOR #-1,TOS \ 1 TOS=-1 if carry was set
244 \ https://forth-standard.org/standard/core/Equal
245 \ = x1 x2 -- flag test x1=x2
252 XOR #-1,TOS \ 1 flag Z = 1
257 \ https://forth-standard.org/standard/core/Uless
258 \ U< u1 u2 -- flag test u1<u2, unsigned
261 SUB @PSP+,TOS \ 2 u2-u1
265 AND #0,TOS \ 1 flag Z = 1
272 [UNDEFINED] < [IF] \ define < and >
273 \ https://forth-standard.org/standard/core/less
274 \ < n1 n2 -- flag test n1<n2, signed
276 SUB @PSP+,TOS \ 1 TOS=n2-n1
277 S< ?GOTO FW1 \ 2 signed
279 BW1 MOV #-1,TOS \ 1 flag Z = 0
284 \ https://forth-standard.org/standard/core/more
285 \ > n1 n2 -- flag test n1>n2, signed
287 SUB @PSP+,TOS \ 2 TOS=n2-n1
288 S< ?GOTO BW1 \ 2 --> +5
289 FW1 AND #0,TOS \ 1 flag Z = 1
294 \ ------------------------------------------------------------------------------
296 \ ------------------------------------------------------------------------------
297 \ THEN and BEGIN compile nothing
298 \ DO compile one word
299 \ IF, ELSE, AGAIN, UNTIL, WHILE, REPEAT, LOOP & +LOOP compile two words
300 \ LEAVE compile three words
302 [UNDEFINED] IF [IF] \ define IF THEN
303 \ https://forth-standard.org/standard/core/IF
304 \ IF -- IFadr initialize conditional forward branch
308 MOV &DP,TOS \ -- HERE
309 ADD #4,&DP \ compile one word, reserve one word
310 MOV #QFBRAN,0(TOS) \ -- HERE compile QFBRAN
311 ADD #2,TOS \ -- HERE+2=IFadr
315 \ https://forth-standard.org/standard/core/THEN
316 \ THEN IFadr -- resolve forward branch
317 CODE THEN \ immediate
318 MOV &DP,0(TOS) \ -- IFadr
324 [UNDEFINED] ELSE [IF]
325 \ https://forth-standard.org/standard/core/ELSE
326 \ ELSE IFadr -- ELSEadr resolve forward IF branch, leave ELSEadr on stack
327 CODE ELSE \ immediate
328 ADD #4,&DP \ make room to compile two words
331 MOV W,0(TOS) \ HERE+4 ==> [IFadr]
333 MOV W,TOS \ -- ELSEadr
338 [UNDEFINED] BEGIN [IF] \ define BEGIN UNTIL AGAIN WHILE REPEAT
339 \ https://forth-standard.org/standard/core/BEGIN
340 \ BEGIN -- BEGINadr initialize backward branch
345 \ https://forth-standard.org/standard/core/UNTIL
346 \ UNTIL BEGINadr -- resolve conditional backward branch
347 CODE UNTIL \ immediate
349 BW1 ADD #4,&DP \ compile two words
351 MOV X,-4(W) \ compile Bran or QFBRAN at HERE
352 MOV TOS,-2(W) \ compile bakcward adr at HERE+2
357 \ https://forth-standard.org/standard/core/AGAIN
358 \ AGAIN BEGINadr -- resolve uncondionnal backward branch
359 CODE AGAIN \ immediate
364 \ https://forth-standard.org/standard/core/WHILE
365 \ WHILE BEGINadr -- WHILEadr BEGINadr
370 \ https://forth-standard.org/standard/core/REPEAT
371 \ REPEAT WHILEadr BEGINadr -- resolve WHILE loop
373 POSTPONE AGAIN POSTPONE THEN
377 [UNDEFINED] DO [IF] \ define DO LOOP +LOOP
378 \ https://forth-standard.org/standard/core/DO
379 \ DO -- DOadr L: -- 0
383 ADD #2,&DP \ make room to compile xdo
384 MOV &DP,TOS \ -- HERE+2
385 MOV #XDO,-2(TOS) \ compile xdo
386 ADD #2,&LEAVEPTR \ -- HERE+2 LEAVEPTR+2
388 MOV #0,0(W) \ -- HERE+2 L-- 0
392 \ https://forth-standard.org/standard/core/LOOP
393 \ LOOP DOadr -- L-- an an-1 .. a1 0
394 CODE LOOP \ immediate
396 BW1 ADD #4,&DP \ make room to compile two words
398 MOV X,-4(W) \ xloop --> HERE
399 MOV TOS,-2(W) \ DOadr --> HERE+2
400 BEGIN \ resolve all "leave" adr
401 MOV &LEAVEPTR,TOS \ -- Adr of top LeaveStack cell
402 SUB #2,&LEAVEPTR \ --
403 MOV @TOS,TOS \ -- first LeaveStack value
404 CMP #0,TOS \ -- = value left by DO ?
406 MOV W,0(TOS) \ move adr after loop as UNLOOP adr
412 \ https://forth-standard.org/standard/core/PlusLOOP
413 \ +LOOP adrs -- L-- an an-1 .. a1 0
414 CODE +LOOP \ immediate
421 \ https://forth-standard.org/standard/core/I
422 \ I -- n R: sys1 sys2 -- sys1 sys2
423 \ get the innermost loop index
425 SUB #2,PSP \ 1 make room in TOS
427 MOV @RSP,TOS \ 2 index = loopctr - fudge
434 \ https://forth-standard.org/standard/core/J
435 \ J -- n R: 4*sys -- 4*sys
436 \ C get the second loop index
446 [UNDEFINED] UNLOOP [IF]
447 \ https://forth-standard.org/standard/core/UNLOOP
448 \ UNLOOP -- R: sys1 sys2 -- drop loop parms
455 [UNDEFINED] LEAVE [IF]
456 \ https://forth-standard.org/standard/core/LEAVE
457 \ LEAVE -- L: -- adrs
459 MOV &DP,W \ compile three words
460 MOV #UNLOOP,0(W) \ [HERE] = UNLOOP
461 MOV #BRAN,2(W) \ [HERE+2] = BRAN
462 ADD #6,&DP \ [HERE+4] = After LOOP adr
466 MOV W,0(X) \ leave HERE+4 on LEAVEPTR stack
472 \ https://forth-standard.org/standard/core/AND
473 \ C AND x1 x2 -- x3 logical AND
481 \ https://forth-standard.org/standard/core/OR
482 \ C OR x1 x2 -- x3 logical OR
490 \ https://forth-standard.org/standard/core/XOR
491 \ C XOR x1 x2 -- x3 logical XOR
499 \ https://forth-standard.org/standard/core/StoD
500 \ S>D n -- d single -> double prec.
507 \ https://forth-standard.org/standard/core/Plus
508 \ + n1/u1 n2/u2 -- n3/u3
516 \ https://forth-standard.org/standard/core/Minus
517 \ - n1/u1 n2/u2 -- n3/u3 n3 = n1-n2
519 SUB @PSP+,TOS \ 2 -- n2-n1 ( = -n3)
521 ADD #1,TOS \ 1 -- n3 = -(n2-n1) = n1-n2
527 \ https://forth-standard.org/standard/core/OnePlus
528 \ 1+ n1/u1 -- n2/u2 add 1 to TOS
536 \ https://forth-standard.org/standard/core/OneMinus
537 \ 1- n1/u1 -- n2/u2 subtract 1 from TOS
544 [UNDEFINED] INVERT [IF]
545 \ https://forth-standard.org/standard/core/INVERT
546 \ INVERT x1 -- x2 bitwise inversion
553 [UNDEFINED] NEGATE [IF]
554 \ https://forth-standard.org/standard/core/NEGATE
555 \ C NEGATE x1 -- x2 two's complement
564 \ https://forth-standard.org/standard/core/ABS
565 \ C ABS n1 -- +n2 absolute value
575 [UNDEFINED] LSHIFT [IF]
576 \ https://forth-standard.org/standard/core/LSHIFT
577 \ LSHIFT x1 u -- x2 logical L shift u places
580 AND #$1F,TOS \ no need to shift more than 16
590 [UNDEFINED] RSHIFT [IF]
591 \ https://forth-standard.org/standard/core/RSHIFT
592 \ RSHIFT x1 u -- x2 logical R7 shift u places
595 AND #$1F,TOS \ no need to shift more than 16
597 BEGIN BIC #C,SR \ Clr Carry
607 \ https://forth-standard.org/standard/core/MAX
608 \ MAX n1 n2 -- n3 signed maximum
616 \ https://forth-standard.org/standard/core/MIN
617 \ MIN n1 n2 -- n3 signed minimum
629 \ https://forth-standard.org/standard/core/TwoTimes
630 \ 2* x1 -- x2 arithmetic left shift
638 \ https://forth-standard.org/standard/core/TwoDiv
639 \ 2/ x1 -- x2 arithmetic right shift
646 \ --------------------
647 \ ARITHMETIC OPERATORS
648 \ --------------------
649 TLV_ORG 4 + @ $81F3 U<
650 $81EF TLV_ORG 4 + @ U<
651 = [IF] ; MSP430FR2xxx|MSP430FR4xxx subfamilies without hardware_MPY
655 \ https://forth-standard.org/standard/core/MTimes
656 \ M* n1 n2 -- dlo dhi signed 16*16->32 multiply
661 XOR #-1,0(PSP) \ n1 --> u1
664 XOR TOS,S \ S contains sign of result
665 CMP #0,TOS \ n2 > -1 ?
667 XOR #-1,TOS \ n2 --> u2
670 PUSHM #2,IP \ UMSTAR use S,T,W,X,Y
674 POPM #2,IP \ pop S,IP
675 CMP #0,S \ sign of result > -1 ?
677 XOR #-1,0(PSP) \ ud --> d
686 [ELSE] ; MSP430FRxxxx with hardware_MPY
689 \ https://forth-standard.org/standard/core/UMTimes
690 \ UM* u1 u2 -- udlo udhi unsigned 16x16->32 mult.
692 MOV @PSP,&MPY \ Load 1st operand for unsigned multiplication
693 BW1 MOV TOS,&OP2 \ Load 2nd operand
694 MOV &RES0,0(PSP) \ low result on stack
695 MOV &RES1,TOS \ high result in TOS
701 \ https://forth-standard.org/standard/core/MTimes
702 \ M* n1 n2 -- dlo dhi signed 16*16->32 multiply
704 MOV @PSP,&MPYS \ Load 1st operand for signed multiplication
709 [THEN] \ endof hardware MPY
711 [UNDEFINED] UM/MOD [IF]
712 \ https://forth-standard.org/standard/core/UMDivMOD
713 \ UM/MOD udlo|udhi u1 -- r q unsigned 32/16->r16 q16
716 MOV #MUSMOD,PC \ execute MUSMOD then return to DROP
720 [UNDEFINED] SM/REM [IF]
721 \ https://forth-standard.org/standard/core/SMDivREM
722 \ SM/REM DVDlo DVDhi DIV -- r3 q4 symmetric signed div
726 CMP #0,TOS \ n2 >= 0 ?
729 ADD #1,TOS \ -- d1 u2
731 CMP #0,0(PSP) \ d1hi >= 0 ?
733 XOR #-1,2(PSP) \ d1lo
734 XOR #-1,0(PSP) \ d1hi
735 ADD #1,2(PSP) \ d1lo+1
736 ADDC #0,0(PSP) \ d1hi+C
737 THEN \ -- uDVDlo uDVDhi uDIVlo
738 PUSHM #3,IP \ save IP,S,T
740 UM/MOD \ -- uREMlo uQUOTlo
742 POPM #3,IP \ restore T,S,IP
743 CMP #0,T \ T=DVDhi --> REM_sign
748 XOR S,T \ S=DIV XOR T=DVDhi = Quot_sign
749 CMP #0,T \ -- n3 u4 T=quot_sign
753 THEN \ -- n3 n4 S=divisor
758 [UNDEFINED] FM/MOD [IF]
759 \ https://forth-standard.org/standard/core/FMDivMOD
760 \ FM/MOD d1 n1 -- r q floored signed div'n
763 HI2LO \ -- remainder quotient S=divisor
764 CMP #0,0(PSP) \ remainder <> 0 ?
766 CMP #1,TOS \ quotient < 1 ?
768 ADD S,0(PSP) \ add divisor to remainder
769 SUB #1,TOS \ decrement quotient
778 \ https://forth-standard.org/standard/core/Times
779 \ * n1 n2 -- n3 signed multiply
785 [UNDEFINED] /MOD [IF]
786 \ https://forth-standard.org/standard/core/DivMOD
787 \ /MOD n1 n2 -- r3 q4 signed division
794 \ https://forth-standard.org/standard/core/Div
795 \ / n1 n2 -- n3 signed quotient
797 >R DUP 0< R> FM/MOD NIP
802 \ https://forth-standard.org/standard/core/MOD
803 \ MOD n1 n2 -- n3 signed remainder
805 >R DUP 0< R> FM/MOD DROP
809 [UNDEFINED] */MOD [IF]
810 \ https://forth-standard.org/standard/core/TimesDivMOD
811 \ */MOD n1 n2 n3 -- r4 q5 signed mult/div
818 \ https://forth-standard.org/standard/core/TimesDiv
819 \ */ n1 n2 n3 -- n4 n1*n2/q3
825 \ -------------------------------------------------------------------------------
827 \ -------------------------------------------------------------------------------
828 [UNDEFINED] OVER [IF]
829 \ https://forth-standard.org/standard/core/OVER
830 \ OVER x1 x2 -- x1 x2 x1
832 MOV TOS,-2(PSP) \ 3 -- x1 (x2) x2
833 MOV @PSP,TOS \ 2 -- x1 (x2) x1
834 SUB #2,PSP \ 1 -- x1 x2 x1
840 \ https://forth-standard.org/standard/core/ROT
841 \ ROT x1 x2 x3 -- x2 x3 x1
843 MOV @PSP,W \ 2 fetch x2
844 MOV TOS,0(PSP) \ 3 store x3
845 MOV 2(PSP),TOS \ 3 fetch x1
846 MOV W,2(PSP) \ 3 store x2
852 \ https://forth-standard.org/standard/core/RFetch
853 \ R@ -- x R: x -- x fetch from return stack
862 \ ----------------------------------------------------------------------
864 \ ----------------------------------------------------------------------
866 \ https://forth-standard.org/standard/core/TwoFetch
867 \ 2@ a-addr -- x1 x2 fetch 2 cells ; the lower address will appear on top of stack
877 \ https://forth-standard.org/standard/core/TwoStore
878 \ 2! x1 x2 a-addr -- store 2 cells ; the top of stack is stored at the lower adr
887 [UNDEFINED] 2DUP [IF]
888 \ https://forth-standard.org/standard/core/TwoDUP
889 \ 2DUP x1 x2 -- x1 x2 x1 x2 dup top 2 cells
898 [UNDEFINED] 2DROP [IF]
899 \ https://forth-standard.org/standard/core/TwoDROP
900 \ 2DROP x1 x2 -- drop 2 cells
908 [UNDEFINED] 2SWAP [IF]
909 \ https://forth-standard.org/standard/core/TwoSWAP
910 \ 2SWAP x1 x2 x3 x4 -- x3 x4 x1 x2
912 MOV @PSP,W \ -- x1 x2 x3 x4 W=x3
913 MOV 4(PSP),0(PSP) \ -- x1 x2 x1 x4
914 MOV W,4(PSP) \ -- x3 x2 x1 x4
915 MOV TOS,W \ -- x3 x2 x1 x4 W=x4
916 MOV 2(PSP),TOS \ -- x3 x2 x1 x2 W=x4
917 MOV W,2(PSP) \ -- x3 x4 x1 x2
922 [UNDEFINED] 2OVER [IF]
923 \ https://forth-standard.org/standard/core/TwoOVER
924 \ 2OVER x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2
926 SUB #4,PSP \ -- x1 x2 x3 x x x4
927 MOV TOS,2(PSP) \ -- x1 x2 x3 x4 x x4
928 MOV 8(PSP),0(PSP) \ -- x1 x2 x3 x4 x1 x4
929 MOV 6(PSP),TOS \ -- x1 x2 x3 x4 x1 x2
934 \ ----------------------------------------------------------------------
935 \ ALIGNMENT OPERATORS
936 \ ----------------------------------------------------------------------
938 [UNDEFINED] ALIGNED [IF]
939 \ https://forth-standard.org/standard/core/ALIGNED
940 \ ALIGNED addr -- a-addr align given addr
948 [UNDEFINED] ALIGN [IF]
949 \ https://forth-standard.org/standard/core/ALIGN
950 \ ALIGN -- align HERE
958 \ ---------------------
959 \ PORTABILITY OPERATORS
960 \ ---------------------
962 [UNDEFINED] CHARS [IF]
963 \ https://forth-standard.org/standard/core/CHARS
964 \ CHARS n1 -- n2 chars->adrs units
970 [UNDEFINED] CHAR+ [IF]
971 \ https://forth-standard.org/standard/core/CHARPlus
972 \ CHAR+ c-addr1 -- c-addr2 add char size
979 [UNDEFINED] CELLS [IF]
980 \ https://forth-standard.org/standard/core/CELLS
981 \ CELLS n1 -- n2 cells->adrs units
988 [UNDEFINED] CELL+ [IF]
989 \ https://forth-standard.org/standard/core/CELLPlus
990 \ CELL+ a-addr1 -- a-addr2 add cell size
997 \ ---------------------------
998 \ BLOCK AND STRING COMPLEMENT
999 \ ---------------------------
1001 [UNDEFINED] CHAR [IF]
1002 \ https://forth-standard.org/standard/core/CHAR
1003 \ CHAR -- char parse ASCII character
1009 [UNDEFINED] [CHAR] [IF]
1010 \ https://forth-standard.org/standard/core/BracketCHAR
1011 \ [CHAR] -- compile character literal
1013 CHAR POSTPONE LITERAL
1018 \ https://forth-standard.org/standard/core/PlusStore
1019 \ +! n/u a-addr -- add n/u to memory
1027 [UNDEFINED] MOVE [IF]
1028 \ https://forth-standard.org/standard/core/MOVE
1029 \ MOVE addr1 addr2 u -- smart move
1030 \ VERSION FOR 1 ADDRESS UNIT = 1 CHAR
1033 MOV @PSP+,Y \ Y = addr2 = dst
1034 MOV @PSP+,X \ X = addr1 = src
1035 MOV @PSP+,TOS \ pop new TOS
1036 CMP #0,W \ count = 0 ?
1037 0<> IF \ if 0, already done !
1038 CMP X,Y \ dst = src ?
1039 0<> IF \ else already done !
1040 U< IF \ U< if src > dst
1041 BEGIN \ copy W bytes
1046 MOV @IP+,PC \ out 1 of MOVE ====>
1047 THEN \ U>= if dst > src
1048 ADD W,Y \ copy W bytes beginning with the end
1058 MOV @IP+,PC \ out 2 of MOVE ====>
1063 [UNDEFINED] FILL [IF]
1064 \ https://forth-standard.org/standard/core/FILL
1065 \ FILL c-addr u char -- fill memory with char
1068 MOV @PSP+,W \ address
1072 MOV.B TOS,0(W) \ store char in memory
1077 MOV @PSP+,TOS \ empties stack
1082 [UNDEFINED] HERE [IF]
1088 \ --------------------
1089 \ INTERPRET COMPLEMENT
1090 \ --------------------
1092 [UNDEFINED] HEX [IF]
1093 \ https://forth-standard.org/standard/core/HEX
1100 [UNDEFINED] DECIMAL [IF]
1101 \ https://forth-standard.org/standard/core/DECIMAL
1109 \ https://forth-standard.org/standard/core/p
1110 \ ( -- skip input until char ) or EOL
1116 [UNDEFINED] .( [IF] \ "
1117 \ https://forth-standard.org/standard/core/Dotp
1118 \ .( -- type comment immediatly.
1120 MOV #0,&CAPS \ CAPS OFF
1124 $20 CAPS ! \ CAPS ON
1128 [UNDEFINED] >BODY [IF]
1129 \ https://forth-standard.org/standard/core/toBODY
1130 \ >BODY -- addr leave BODY of a CREATEd word\ also leave default ACTION-OF primary DEFERred word
1137 [UNDEFINED] EXECUTE [IF] \ "
1138 \ https://forth-standard.org/standard/core/EXECUTE
1139 \ EXECUTE i*x xt -- j*x execute Forth word at 'xt'
1141 PUSH TOS \ 3 push xt
1143 MOV @RSP+,PC \ 4 xt --> PC
1147 [UNDEFINED] EVALUATE [IF]
1148 \ https://forth-standard.org/standard/core/EVALUATE
1149 \ EVALUATE \ i*x c-addr u -- j*x interpret string
1151 MOV #SOURCE_LEN,X \ 2
1152 MOV @X+,S \ 2 S = SOURCE_LEN
1153 MOV @X+,T \ 2 T = SOURCE_ORG
1154 MOV @X+,W \ 2 W = TOIN
1155 PUSHM #4,IP \ 6 PUSHM IP,S,T,W
1160 MOV @RSP+,&SOURCE_ORG \ 4
1161 MOV @RSP+,&SOURCE_LEN \ 4
1167 [UNDEFINED] RECURSE [IF]
1168 \ https://forth-standard.org/standard/core/RECURSE
1169 \ C RECURSE -- recurse to current definition
1178 [UNDEFINED] SOURCE [IF]
1179 \ https://forth-standard.org/standard/core/SOURCE
1180 \ SOURCE -- adr u of current input buffer
1185 MOV &SOURCE_ORG,0(PSP)
1190 [UNDEFINED] DOES> [IF]
1191 \ https://forth-standard.org/standard/core/DOES
1192 \ DOES> -- set action for the latest CREATEd definition
1194 MOV &LAST_CFA,W \ W = CFA of CREATEd word
1195 MOV #$1285,0(W) \ replace CFA (CALL rDOCON) by new CFA (CALL rDODOES)
1196 MOV IP,2(W) \ replace PFA by the address after DOES> as execution address
1202 [UNDEFINED] VARIABLE [IF]
1203 \ https://forth-standard.org/standard/core/VARIABLE
1204 \ VARIABLE <name> -- define a Forth VARIABLE
1208 MOV #$1287,-4(W) \ CFA = CALL rDOVAR
1214 [UNDEFINED] CONSTANT [IF]
1215 \ https://forth-standard.org/standard/core/CONSTANT
1216 \ CONSTANT <name> n -- define a Forth CONSTANT
1220 MOV TOS,-2(W) \ PFA = n
1227 [UNDEFINED] STATE [IF]
1228 \ https://forth-standard.org/standard/core/STATE
1229 \ STATE -- a-addr holds compiler state
1230 STATEADR CONSTANT STATE
1233 [UNDEFINED] BASE [IF]
1234 \ https://forth-standard.org/standard/core/BASE
1235 \ BASE -- a-addr holds conversion radix
1236 BASEADR CONSTANT BASE
1239 [UNDEFINED] >IN [IF]
1240 \ https://forth-standard.org/standard/core/toIN
1241 \ C >IN -- a-addr holds offset in input stream
1245 [UNDEFINED] PAD [IF]
1246 \ https://forth-standard.org/standard/core/PAD
1248 PAD_ORG CONSTANT PAD
1252 \ https://forth-standard.org/standard/core/BL
1253 \ BL -- char an ASCII space
1257 [UNDEFINED] SPACE [IF]
1258 \ https://forth-standard.org/standard/core/SPACE
1259 \ SPACE -- output a space
1264 [UNDEFINED] SPACES [IF]
1265 \ https://forth-standard.org/standard/core/SPACES
1266 \ SPACES n -- output n spaces
1280 MOV @PSP+,TOS \ -- drop n
1286 \ https://forth-standard.org/standard/core/TO
1287 \ TO name Run-time: ( x -- )
1288 \ Assign the value x to named VALUE.
1295 [UNDEFINED] VALUE [IF]
1296 \ https://forth-standard.org/standard/core/VALUE
1297 \ ( x "<spaces>name" -- ) define a Forth VALUE
1298 \ Skip leading space delimiters. Parse name delimited by a space.
1299 \ Create a definition for name with the execution semantics defined below,
1300 \ with an initial value equal to x.
1302 \ name Execution: ( -- x )
1303 \ Place x on the stack. The value of x is that given when name was created,
1304 \ until the phrase x TO name is executed, causing a new value of x to be assigned to name.
1306 : VALUE \ x "<spaces>name" --
1311 BIT #UF9,SR \ 2 see TO
1312 0= IF \ 2 execute FETCH
1316 BIC #UF9,SR \ 2 clear 'TO' flag
1317 MOV @PSP+,0(TOS) \ 4 execute STORE
1325 [THEN] \ end of [UNDEFINED] {CORE_ANS}
1328 ; CORE_ANS.f is loaded