1 \ -*- coding: utf-8 -*-
3 \ TARGET SELECTION ( = the name of \INC\target.pat file without the extension)
4 \ (used by preprocessor GEMA to load the pattern: \inc\TARGET.pat)
5 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
6 \ MSP_EXP430FR4133 CHIPSTICK_FR2433 MSP_EXP430FR2433 MSP_EXP430FR2355
10 \ from scite editor : copy your target selection in (shift+F8) parameter 1:
14 \ drag and drop this file onto SendSourceFileToTarget.bat
15 \ then select your TARGET when asked.
19 \ rDODOES to rEXIT must be saved before use and restored after
20 \ scratch registers Y to S are free for use
21 \ under interrupt, IP is free for use
23 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, rEXIT, rDOVAR, rDOCON, rDODOES
24 \ example : PUSHM #6,IP pushes IP,S,T,W,X,Y registers to return stack
26 \ POPM order : rDODOES, rDOCON, rDOVAR, rEXIT, Y, X, W, T, S, IP,TOS,PSP
27 \ example : POPM #6,IP pulls Y,X,W,T,S,IP registers from return stack
29 \ FORTH conditionnals: unary{ 0= 0< 0> }, binary{ = < > U< }
31 \ ASSEMBLER conditionnal usage with IF UNTIL WHILE S< S>= U< U>= 0= 0<> 0>=
32 \ ASSEMBLER conditionnal usage with ?GOTO S< S>= U< U>= 0= 0<> 0<
38 SUB #401,TOS \ FastForth V4.1
40 'CR' EMIT \ return to column 1, no 'LF'
41 ABORT" FastForth V4.1 please!"
48 \ BC! pattern @ -- Bits Clear in @
58 \ BS! pattern @ -- Bits Set in @
66 \ =============================================================================
67 $8000 KERNEL_ADDON BC! \ uncomment to select SYMMETRIC division
68 \ $8000 KERNEL_ADDON BS! \ uncomment to select FLOORED division
69 \ =============================================================================
71 RST_RET \ remove all above before CORE_ANS downloading
73 ; ----------------------------------
75 ; ----------------------------------
77 \ words complement to pass CORETEST.4TH
80 [IF] {TEST} [THEN] \ if already defined removes it before.
89 \ https://forth-standard.org/standard/core/ABORT
90 \ Empty the data stack and perform the function of QUIT
92 MOV #ABORT,PC \ addr defined in MSP430FRxxxx.pat
98 \ https://forth-standard.org/standard/core/QUIT
99 \ Empty the return stack, store zero in SOURCE-ID if it is present,
100 \ make the user input device the input source, and enter interpretation state.
101 \ Do not display a message. Repeat the following:
102 \ Accept a line from the input source into the input buffer, set >IN to zero, and interpret.
103 \ Display the implementation-defined system prompt if in interpretation state,
104 \ all processing has been completed,
105 \ and no ambiguous condition exists.
107 MOV #QUIT,PC \ addr defined in MSP430FRxxxx.pat
113 \ https://forth-standard.org/standard/core/HERE
114 \ HERE -- addr addr is the data-space pointer.
116 MOV #BEGIN,PC \ execute ASM BEGIN
122 \ https://forth-standard.org/standard/core/Plus
123 \ + n1/u1 n2/u2 -- n3/u3 add n1+n2
132 \ https://forth-standard.org/standard/core/Minus
133 \ - n1/u1 n2/u2 -- n3/u3 n3 = n1-n2
135 SUB @PSP+,TOS \ 2 -- n2-n1 ( = -n3)
137 ADD #1,TOS \ 1 -- n3 = -(n2-n1) = n1-n2
143 [IF] \ define DUP and ?DUP
145 \ https://forth-standard.org/standard/core/DUP
146 \ DUP x -- x x duplicate top of stack
148 BW1 SUB #2,PSP \ 2 push old TOS..
149 MOV TOS,0(PSP) \ 3 ..onto stack
153 \ https://forth-standard.org/standard/core/qDUP
154 \ ?DUP x -- 0 | x x DUP if nonzero
156 CMP #0,TOS \ 2 test for TOS nonzero
164 \ https://forth-standard.org/standard/core/EXIT
165 \ EXIT -- exit a colon definition
167 MOV @RSP+,IP \ 2 pop previous IP (or next PC) from return stack
168 MOV @IP+,PC \ 4 = NEXT
174 \ https://forth-standard.org/standard/core/DEPTH
175 \ DEPTH -- +n number of items on stack, must leave 0 if stack empty
179 SUB PSP,TOS \ PSP-S0--> TOS
180 RRA TOS \ TOS/2 --> TOS
181 SUB #2,PSP \ post decrement stack...
188 \ https://forth-standard.org/standard/core/SWAP
189 \ SWAP x1 x2 -- x2 x1 swap top two items
200 \ https://forth-standard.org/standard/core/DROP
201 \ DROP x -- drop top of stack
210 \ https://forth-standard.org/standard/core/OVER
211 \ OVER x1 x2 -- x1 x2 x1
213 MOV TOS,-2(PSP) \ 3 -- x1 (x2) x2
214 MOV @PSP,TOS \ 2 -- x1 (x2) x1
215 SUB #2,PSP \ 1 -- x1 x2 x1
222 \ https://forth-standard.org/standard/core/NIP
223 \ NIP x1 x2 -- x2 Drop the first item below the top of stack
232 \ https://forth-standard.org/standard/core/toR
233 \ >R x -- R: -- x push to return stack
243 \ https://forth-standard.org/standard/core/Rfrom
244 \ R> -- x R: x -- pop from return stack
255 \ https://forth-standard.org/standard/core/Fetch
256 \ C@ c-addr -- char fetch char from memory
265 \ https://forth-standard.org/standard/core/CStore
266 \ C! char c-addr -- store char in memory
268 MOV.B @PSP+,0(TOS) \ 4
277 \ https://forth-standard.org/standard/core/CComma
278 \ C, char -- append char
290 \ https://forth-standard.org/standard/core/ZeroEqual
291 \ 0= n/u -- flag return true if TOS=0
293 SUB #1,TOS \ 1 borrow (clear cy) if TOS was 0
294 SUBC TOS,TOS \ 1 TOS=-1 if borrow was set
301 \ https://forth-standard.org/standard/core/Zerone
302 \ 0<> n/u -- flag return true if TOS<>0
304 SUB #1,TOS \ 1 borrow (clear cy) if TOS was 0
305 SUBC TOS,TOS \ 1 TOS=-1 if borrow was set
313 \ https://forth-standard.org/standard/core/Zeroless
314 \ 0< n -- flag true if TOS negative
316 ADD TOS,TOS \ 1 set carry if TOS negative
317 SUBC TOS,TOS \ 1 TOS=-1 if carry was clear
318 XOR #-1,TOS \ 1 TOS=-1 if carry was set
325 \ https://forth-standard.org/standard/core/StoD
326 \ S>D n -- d single -> double prec.
334 \ https://forth-standard.org/standard/core/Equal
335 \ = x1 x2 -- flag test x1=x2
338 SUB #1,TOS \ 1 borrow (clear cy) if TOS was 0
339 SUBC TOS,TOS \ 1 TOS=-1 if borrow was set
347 \ https://forth-standard.org/standard/core/Umore
351 U< ?GOTO FW1 \ 2 flag = true, Z = 0
352 BW1 AND #0,TOS \ 1 Z = 1
356 \ https://forth-standard.org/standard/core/Uless
357 \ U< u1 u2 -- flag test u1<u2, unsigned
359 SUB @PSP+,TOS \ 2 u2-u1
368 [IF] \ define < and >
370 \ https://forth-standard.org/standard/core/more
371 \ > n1 n2 -- flag test n1>n2, signed
373 SUB @PSP+,TOS \ 2 TOS=n2-n1
374 S< ?GOTO FW1 \ 2 --> +5
375 BW1 AND #0,TOS \ 1 flag Z = 1
379 \ https://forth-standard.org/standard/core/less
380 \ < n1 n2 -- flag test n1<n2, signed
382 SUB @PSP+,TOS \ 1 TOS=n2-n1
384 S< ?GOTO BW1 \ 2 signed
385 FW1 MOV #-1,TOS \ 1 flag Z = 0
390 \ ------------------------------------------------------------------------------
392 \ ------------------------------------------------------------------------------
393 \ THEN and BEGIN compile nothing
394 \ DO compile one word
395 \ IF, ELSE, AGAIN, UNTIL, WHILE, REPEAT, LOOP & +LOOP compile two words
396 \ LEAVE compile three words
399 [IF] \ define IF THEN
401 \ https://forth-standard.org/standard/core/IF
402 \ IF -- IFadr initialize conditional forward branch
406 MOV &DP,TOS \ -- HERE
407 ADD #4,&DP \ compile one word, reserve one word
408 MOV #QFBRAN,0(TOS) \ -- HERE compile QFBRAN
409 ADD #2,TOS \ -- HERE+2=IFadr
413 \ https://forth-standard.org/standard/core/THEN
414 \ THEN IFadr -- resolve forward branch
416 MOV &DP,0(TOS) \ -- IFadr
424 \ https://forth-standard.org/standard/core/ELSE
425 \ ELSE IFadr -- ELSEadr resolve forward IF branch, leave ELSEadr on stack
427 ADD #4,&DP \ make room to compile two words
430 MOV W,0(TOS) \ HERE+4 ==> [IFadr]
432 MOV W,TOS \ -- ELSEadr
438 [IF] \ define BEGIN UNTIL AGAIN WHILE REPEAT
440 \ https://forth-standard.org/standard/core/BEGIN
441 \ BEGIN -- BEGINadr initialize backward branch
443 MOV #BEGIN,PC \ execute ASM BEGIN !
446 \ https://forth-standard.org/standard/core/UNTIL
447 \ UNTIL BEGINadr -- resolve conditional backward branch
450 BW1 ADD #4,&DP \ compile two words
452 MOV X,-4(W) \ compile Bran or QFBRAN at HERE
453 MOV TOS,-2(W) \ compile bakcward adr at HERE+2
458 \ https://forth-standard.org/standard/core/AGAIN
459 \ AGAIN BEGINadr -- resolve uncondionnal backward branch
465 \ https://forth-standard.org/standard/core/WHILE
466 \ WHILE BEGINadr -- WHILEadr BEGINadr
471 \ https://forth-standard.org/standard/core/REPEAT
472 \ REPEAT WHILEadr BEGINadr -- resolve WHILE loop
474 POSTPONE AGAIN POSTPONE THEN
479 [IF] \ define DO LOOP +LOOP
481 HDNCODE XDO \ DO run time
482 MOV #$8000,X \ 2 compute 8000h-limit = "fudge factor"
484 MOV TOS,Y \ 1 loop ctr = index+fudge
485 ADD X,Y \ 1 Y = INDEX
486 PUSHM #2,X \ 4 PUSHM X,Y, i.e. PUSHM LIMIT, INDEX
491 \ https://forth-standard.org/standard/core/DO
492 \ DO -- DOadr L: -- 0
496 ADD #2,&DP \ make room to compile xdo
497 MOV &DP,TOS \ -- HERE+2
498 MOV #XDO,-2(TOS) \ compile xdo
499 ADD #2,&LEAVEPTR \ -- HERE+2 LEAVEPTR+2
501 MOV #0,0(W) \ -- HERE+2 L-- 0, init
505 HDNCODE XLOOP \ LOOP run time
506 ADD #1,0(RSP) \ 4 increment INDEX
507 BW1 BIT #$100,SR \ 2 is overflow bit set?
508 0= IF \ branch if no overflow
512 ADD #4,RSP \ 1 empties RSP
513 ADD #2,IP \ 1 overflow = loop done, skip branch ofs
514 MOV @IP+,PC \ 4 14~ taken or not taken xloop/loop
517 \ https://forth-standard.org/standard/core/LOOP
518 \ LOOP DOadr -- L-- an an-1 .. a1 0
521 BW2 ADD #4,&DP \ make room to compile two words
523 MOV X,-4(W) \ xloop --> HERE
524 MOV TOS,-2(W) \ DOadr --> HERE+2
525 BEGIN \ resolve all "leave" adr
526 MOV &LEAVEPTR,TOS \ -- Adr of top LeaveStack cell
527 SUB #2,&LEAVEPTR \ --
528 MOV @TOS,TOS \ -- first LeaveStack value
529 CMP #0,TOS \ -- = value left by DO ?
531 MOV W,0(TOS) \ move adr after loop as UNLOOP adr
537 \ https://forth-standard.org/standard/core/PlusLOOP
538 \ +LOOP adrs -- L-- an an-1 .. a1 0
539 HDNCODE XPLOO \ +LOOP run time
540 ADD TOS,0(RSP) \ 4 increment INDEX by TOS value
541 MOV @PSP+,TOS \ 2 get new TOS, doesn't change flags
553 \ https://forth-standard.org/standard/core/I
554 \ I -- n R: sys1 sys2 -- sys1 sys2
555 \ get the innermost loop index
557 SUB #2,PSP \ 1 make room in TOS
559 MOV @RSP,TOS \ 2 index = loopctr - fudge
567 \ https://forth-standard.org/standard/core/J
568 \ J -- n R: 4*sys -- 4*sys
569 \ C get the second loop index
581 \ https://forth-standard.org/standard/core/UNLOOP
582 \ UNLOOP -- R: sys1 sys2 -- drop loop parms
591 \ https://forth-standard.org/standard/core/LEAVE
592 \ LEAVE -- L: -- adrs
594 MOV &DP,W \ compile three words
595 MOV #UNLOOP,0(W) \ [HERE] = UNLOOP
596 MOV #BRAN,2(W) \ [HERE+2] = BRAN
597 ADD #6,&DP \ [HERE+4] = at adr After LOOP
601 MOV W,0(X) \ leave HERE+4 on LEAVEPTR stack
608 \ https://forth-standard.org/standard/core/AND
609 \ C AND x1 x2 -- x3 logical AND
618 \ https://forth-standard.org/standard/core/OR
619 \ C OR x1 x2 -- x3 logical OR (BIS, BIts Set)
622 AND #-1,TOS \ to set flags
629 \ https://forth-standard.org/standard/core/XOR
630 \ C XOR x1 x2 -- x3 logical XOR
639 \ https://forth-standard.org/standard/core/OnePlus
640 \ 1+ n1/u1 -- n2/u2 add 1 to TOS
649 \ https://forth-standard.org/standard/core/OneMinus
650 \ 1- n1/u1 -- n2/u2 subtract 1 from TOS
659 \ https://forth-standard.org/standard/core/INVERT
660 \ INVERT x1 -- x2 bitwise inversion
669 \ https://forth-standard.org/standard/core/NEGATE
670 \ C NEGATE x1 -- x2 two's complement
680 \ https://forth-standard.org/standard/core/ABS
681 \ C ABS n1 -- +n2 absolute value
693 \ https://forth-standard.org/standard/core/LSHIFT
694 \ LSHIFT x1 u -- x2 logical L shift u places
697 AND #$1F,TOS \ no need to shift more than 16
711 \ https://forth-standard.org/standard/core/RSHIFT
712 \ RSHIFT x1 u -- x2 logical R7 shift u places
715 AND #$1F,TOS \ no need to shift more than 16
718 BIC #C,SR \ Clr Carry
730 \ https://forth-standard.org/standard/core/MAX
731 \ MAX n1 n2 -- n3 signed maximum
739 \ https://forth-standard.org/standard/core/MIN
740 \ MIN n1 n2 -- n3 signed minimum
751 \ https://forth-standard.org/standard/core/TwoTimes
752 \ 2* x1 -- x2 arithmetic left shift
761 \ https://forth-standard.org/standard/core/TwoDiv
762 \ 2/ x1 -- x2 arithmetic right shift
769 \ --------------------
770 \ ARITHMETIC OPERATORS
771 \ --------------------
774 CODE TSTBIT \ addr bit_mask -- true/flase flag
780 \ $81EF DEVICEID @ U<
781 \ DEVICEID @ $81F3 U<
782 \ = [IF] ; MSP430FR413x subfamily without hardware_MPY
783 KERNEL_ADDON HMPY TSTBIT \ KERNEL_ADDON(BIT0) = hardware MPY flag
787 [IF] ; MSP430FR413x subfamily with hardware_MPY
791 \ https://forth-standard.org/standard/core/MTimes
792 \ M* n1 n2 -- dlo dhi signed 16*16->32 multiply
794 MOV @PSP,&MPY \ Load 1st operand for unsigned multiplication
795 BW1 MOV TOS,&OP2 \ Load 2nd operand
796 MOV &RES0,0(PSP) \ low result on stack
797 MOV &RES1,TOS \ high result in TOS
804 \ https://forth-standard.org/standard/core/MTimes
805 \ M* n1 n2 -- dlo dhi signed 16*16->32 multiply
807 MOV @PSP,&MPYS \ Load 1st operand for signed multiplication
812 [ELSE] ; MSP430FRxxxx without hardware_MPY
816 \ https://forth-standard.org/standard/core/UMTimes
817 \ UM* u1 u2 -- udlo udhi unsigned 16x16->32 mult.
822 XOR #-1,0(PSP) \ n1 --> u1
825 XOR TOS,S \ S contains sign of result
826 CMP #0,TOS \ n2 > -1 ?
828 XOR #-1,TOS \ n2 --> u2
831 PUSHM #2,IP \ UMSTAR use S,T,W,X,Y
835 POPM #2,IP \ pop S,IP
836 CMP #0,S \ sign of result > -1 ?
838 XOR #-1,0(PSP) \ ud --> d
846 [THEN] ; endof hardware_MPY
850 \ https://forth-standard.org/standard/core/UMDivMOD
851 \ UM/MOD udlo|udhi u1 -- r q unsigned 32/16->r16 q16
854 MOV #MUSMOD,PC \ execute MUSMOD then return to DROP
858 KERNEL_ADDON @ 0< ; test the switch: FLOORED / SYMETRIC DIVISION
862 \ https://forth-standard.org/standard/core/FMDivMOD
863 \ FM/MOD d1 n1 -- r q floored signed div'n
867 CMP #0,TOS \ n2 >= 0 ?
870 ADD #1,TOS \ -- d1 u2
872 CMP #0,0(PSP) \ d1hi >= 0 ?
874 XOR #-1,2(PSP) \ d1lo
875 XOR #-1,0(PSP) \ d1hi
876 ADD #1,2(PSP) \ d1lo+1
877 ADDC #0,0(PSP) \ d1hi+C
878 THEN \ -- uDVDlo uDVDhi uDIVlo
879 PUSHM #2,S \ 4 PUSHM S,T
882 POPM #2,S \ 4 POPM T,S
883 CMP #0,T \ T=DVDhi --> REM_sign
888 XOR S,T \ S=DIV XOR T=DVDhi = Quot_sign
889 CMP #0,T \ -- n3 u4 T=quot_sign
893 THEN \ -- n3 n4 S=divisor
895 CMP #0,0(PSP) \ remainder <> 0 ?
897 CMP #1,TOS \ quotient < 1 ?
899 ADD S,0(PSP) \ add divisor to remainder
900 SUB #1,TOS \ decrement quotient
909 \ https://forth-standard.org/standard/core/SMDivREM
910 \ SM/REM DVDlo DVDhi DIV -- r3 q4 symmetric signed div
914 CMP #0,TOS \ n2 >= 0 ?
917 ADD #1,TOS \ -- d1 u2
919 CMP #0,0(PSP) \ d1hi >= 0 ?
921 XOR #-1,2(PSP) \ d1lo
922 XOR #-1,0(PSP) \ d1hi
923 ADD #1,2(PSP) \ d1lo+1
924 ADDC #0,0(PSP) \ d1hi+C
925 THEN \ -- uDVDlo uDVDhi uDIVlo
926 PUSHM #2,S \ 4 PUSHM S,T
929 POPM #2,S \ 4 POPM T,S
930 CMP #0,T \ T=DVDhi --> REM_sign
935 XOR S,T \ S=DIV XOR T=DVDhi = Quot_sign
936 CMP #0,T \ -- n3 u4 T=quot_sign
940 THEN \ -- n3 n4 S=divisor
948 \ https://forth-standard.org/standard/core/Times
949 \ * n1 n2 -- n3 signed multiply
957 \ https://forth-standard.org/standard/core/DivMOD
958 \ /MOD n1 n2 -- r3 q4 signed division
961 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
970 \ https://forth-standard.org/standard/core/Div
971 \ / n1 n2 -- n3 signed quotient
974 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
984 \ https://forth-standard.org/standard/core/MOD
985 \ MOD n1 n2 -- n3 signed remainder
988 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
998 \ https://forth-standard.org/standard/core/TimesDivMOD
999 \ */MOD n1 n2 n3 -- r4 q5 signed mult/div
1002 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
1011 \ https://forth-standard.org/standard/core/TimesDiv
1012 \ */ n1 n2 n3 -- n4 n1*n2/q3
1015 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
1023 \ -------------------------------------------------------------------------------
1025 \ -------------------------------------------------------------------------------
1028 \ https://forth-standard.org/standard/core/ROT
1029 \ ROT x1 x2 x3 -- x2 x3 x1
1031 MOV @PSP,W \ 2 fetch x2
1032 MOV TOS,0(PSP) \ 3 store x3
1033 MOV 2(PSP),TOS \ 3 fetch x1
1034 MOV W,2(PSP) \ 3 store x2
1041 \ https://forth-standard.org/standard/core/RFetch
1042 \ R@ -- x R: x -- x fetch from return stack
1053 \ https://forth-standard.org/standard/core/TUCK
1054 \ TUCK ( x1 x2 -- x2 x1 x2 )
1058 \ ----------------------------------------------------------------------
1060 \ ----------------------------------------------------------------------
1063 \ https://forth-standard.org/standard/core/TwoFetch
1064 \ 2@ a-addr -- x1 x2 fetch 2 cells ; the lower address will appear on top of stack
1075 \ https://forth-standard.org/standard/core/TwoStore
1076 \ 2! x1 x2 a-addr -- store 2 cells ; the top of stack is stored at the lower adr
1087 \ https://forth-standard.org/standard/core/TwoDUP
1088 \ 2DUP x1 x2 -- x1 x2 x1 x2 dup top 2 cells
1091 MOV @PSP,-4(PSP) \ 4
1099 \ https://forth-standard.org/standard/core/TwoDROP
1100 \ 2DROP x1 x2 -- drop 2 cells
1110 \ https://forth-standard.org/standard/core/TwoSWAP
1111 \ 2SWAP x1 x2 x3 x4 -- x3 x4 x1 x2
1113 MOV @PSP,W \ -- x1 x2 x3 x4 W=x3
1114 MOV 4(PSP),0(PSP) \ -- x1 x2 x1 x4
1115 MOV W,4(PSP) \ -- x3 x2 x1 x4
1116 MOV TOS,W \ -- x3 x2 x1 x4 W=x4
1117 MOV 2(PSP),TOS \ -- x3 x2 x1 x2 W=x4
1118 MOV W,2(PSP) \ -- x3 x4 x1 x2
1125 \ https://forth-standard.org/standard/core/TwoOVER
1126 \ 2OVER x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2
1128 SUB #4,PSP \ -- x1 x2 x3 x x x4
1129 MOV TOS,2(PSP) \ -- x1 x2 x3 x4 x x4
1130 MOV 8(PSP),0(PSP) \ -- x1 x2 x3 x4 x1 x4
1131 MOV 6(PSP),TOS \ -- x1 x2 x3 x4 x1 x2
1136 \ ----------------------------------------------------------------------
1137 \ ALIGNMENT OPERATORS
1138 \ ----------------------------------------------------------------------
1141 \ https://forth-standard.org/standard/core/ALIGNED
1142 \ ALIGNED addr -- a-addr align given addr
1152 \ https://forth-standard.org/standard/core/ALIGN
1153 \ ALIGN -- align HERE
1161 \ ---------------------
1162 \ PORTABILITY OPERATORS
1163 \ ---------------------
1166 \ https://forth-standard.org/standard/core/CHARS
1167 \ CHARS n1 -- n2 chars->adrs units
1175 \ https://forth-standard.org/standard/core/CHARPlus
1176 \ CHAR+ c-addr1 -- c-addr2 add char size
1185 \ https://forth-standard.org/standard/core/CELLS
1186 \ CELLS n1 -- n2 cells->adrs units
1195 \ https://forth-standard.org/standard/core/CELLPlus
1196 \ CELL+ a-addr1 -- a-addr2 add cell size
1203 \ ---------------------------
1204 \ BLOCK AND STRING COMPLEMENT
1205 \ ---------------------------
1208 \ https://forth-standard.org/standard/core/CHAR
1209 \ CHAR -- char parse ASCII character
1217 \ https://forth-standard.org/standard/core/BracketCHAR
1218 \ [CHAR] -- compile character literal
1220 CHAR POSTPONE LITERAL
1226 \ https://forth-standard.org/standard/core/PlusStore
1227 \ +! n/u a-addr -- add n/u to memory
1237 \ https://forth-standard.org/standard/core/MOVE
1238 \ MOVE addr1 addr2 u -- smart move
1239 \ VERSION FOR 1 ADDRESS UNIT = 1 CHAR
1242 MOV @PSP+,Y \ Y = addr2 = dst
1243 MOV @PSP+,X \ X = addr1 = src
1244 MOV @PSP+,TOS \ pop new TOS
1245 CMP #0,W \ count = 0 ?
1246 0<> IF \ if 0, already done !
1247 CMP X,Y \ dst = src ?
1248 0<> IF \ if 0, already done !
1249 U< IF \ U< if src > dst
1250 BEGIN \ copy W bytes
1255 MOV @IP+,PC \ out 1 of MOVE ====>
1256 THEN \ U>= if dst > src
1257 ADD W,Y \ copy W bytes beginning with the end
1267 MOV @IP+,PC \ out 2 of MOVE ====>
1273 \ https://forth-standard.org/standard/core/FILL
1274 \ FILL c-addr u char -- fill memory with char
1277 MOV @PSP+,W \ address
1281 MOV.B TOS,0(W) \ store char in memory
1286 MOV @PSP+,TOS \ empties stack
1291 \ --------------------
1292 \ INTERPRET COMPLEMENT
1293 \ --------------------
1296 \ https://forth-standard.org/standard/core/HEX
1305 \ https://forth-standard.org/standard/core/DECIMAL
1314 \ https://forth-standard.org/standard/core/p
1315 \ ( -- skip input until char ) or EOL
1323 \ https://forth-standard.org/standard/core/Dotp
1324 \ .( -- type comment immediatly.
1327 MOV #0,&CAPS \ CAPS OFF
1332 MOV #$20,&CAPS \ CAPS ON
1340 \ https://forth-standard.org/standard/core/toBODY
1341 \ >BODY -- addr leave BODY of a CREATEd word\ also leave default ACTION-OF primary DEFERred word
1350 \ https://forth-standard.org/standard/core/EXECUTE
1351 \ EXECUTE i*x xt -- j*x execute Forth word at 'xt'
1353 PUSH TOS \ 3 push xt
1355 MOV @RSP+,PC \ 4 xt --> PC
1359 [UNDEFINED] EVALUATE
1362 \ EVALUATE upside down...
1363 CODENNM \ as the end of EVALUATE
1365 MOV @RSP+,&SOURCE_ORG \ 4
1366 MOV @RSP+,&SOURCE_LEN \ 4
1369 ENDCODE \ -- end_of_EVALUATE_addr
1371 \ https://forth-standard.org/standard/core/EVALUATE
1372 \ EVALUATE \ i*x c-addr u -- j*x interpret string
1374 MOV #SOURCE_LEN,X \ 2
1375 MOV @X+,S \ 2 S = SOURCE_LEN
1376 MOV @X+,T \ 2 T = SOURCE_ORG
1377 MOV @X+,W \ 2 W = TOIN
1378 PUSHM #4,IP \ 6 PUSHM IP,S,T,W
1380 ADD #8,IP \ 1 IP = address compiled after ENDCODE
1381 MOV #INTERPRET,PC \ 3 addr defined in MSP430FRxxxx.pat
1382 NOP \ 1 stuffing instruction
1384 , \ end_of_EVALUATE_addr -- compile the end_of_EVALUATE_addr
1390 \ https://forth-standard.org/standard/core/RECURSE
1391 \ C RECURSE -- recurse to current definition
1402 \ https://forth-standard.org/standard/core/SOURCE
1403 \ SOURCE -- adr u of current input buffer
1408 MOV &SOURCE_ORG,0(PSP)
1413 [UNDEFINED] VARIABLE
1415 \ https://forth-standard.org/standard/core/VARIABLE
1416 \ VARIABLE <name> -- define a Forth VARIABLE
1420 MOV #DOVAR,-4(W) \ CFA = CALL rDOVAR
1426 [UNDEFINED] CONSTANT
1428 \ https://forth-standard.org/standard/core/CONSTANT
1429 \ CONSTANT <name> n -- define a Forth CONSTANT
1433 MOV TOS,-2(W) \ PFA = n
1442 \ https://forth-standard.org/standard/core/STATE
1443 \ STATE -- a-addr holds compiler state
1444 STATEADR CONSTANT STATE
1449 \ https://forth-standard.org/standard/core/BASE
1450 \ BASE -- a-addr holds conversion radix
1451 BASEADR CONSTANT BASE
1456 \ https://forth-standard.org/standard/core/toIN
1457 \ C >IN -- a-addr holds offset in input stream
1463 \ https://forth-standard.org/standard/core/PAD
1465 PAD_ORG CONSTANT PAD
1470 \ https://forth-standard.org/standard/core/BL
1471 \ BL -- char an ASCII space
1477 \ https://forth-standard.org/standard/core/SPACE
1478 \ SPACE -- output a space
1485 \ https://forth-standard.org/standard/core/SPACES
1486 \ SPACES n -- output n spaces
1499 \ https://forth-standard.org/standard/core/DEFER
1500 \ Skip leading space delimiters. Parse name delimited by a space.
1501 \ Create a definition for name with the execution semantics defined below.
1503 \ name Execution: --
1504 \ Execute the xt that name is set to execute, i.e. NEXT (nothing),
1505 \ until the phrase ' word IS name is executed, causing a new value of xt to be assigned to name.
1509 MOV #$4030,-4(W) \4 first CELL = MOV @PC+,PC = BR #addr
1510 MOV #NEXT_ADR,-2(W) \3 second CELL = ...mNEXT : do nothing by default
1518 \ https://forth-standard.org/standard/core/CR
1519 \ CR -- send CR+LF to the output device
1520 \ DEFER CR \ DEFERed definition, by default executes :NONAME part
1521 CODE CR \ DEFERed definition replaced by this CODE definition
1532 \ https://forth-standard.org/standard/core/TO
1533 \ TO name Run-time: ( x -- )
1534 \ Assign the value x to named VALUE.
1543 \ https://forth-standard.org/standard/core/VALUE
1544 \ ( x "<spaces>name" -- ) define a Forth VALUE
1545 \ Skip leading space delimiters. Parse name delimited by a space.
1546 \ Create a definition for name with the execution semantics defined below,
1547 \ with an initial value equal to x.
1549 \ name Execution: ( -- x )
1550 \ Place x on the stack. The value of x is that given when name was created,
1551 \ until the phrase x TO name is executed, causing a new value of x to be assigned to name.
1552 : VALUE \ x "<spaces>name" --
1557 BIT #UF9,SR \ 2 see TO
1558 0= IF \ 2 if UF9 is not set
1559 MOV @TOS,TOS \ 2 execute FETCH
1562 BIC #UF9,SR \ 2 clear UF9 flag
1563 MOV #!,PC \ 4 execute STORE
1568 [IF] \ define CASE OF ENDOF ENDCASE
1570 \ https://forth-standard.org/standard/core/CASE
1572 ; IMMEDIATE \ -- #of-1
1574 \ https://forth-standard.org/standard/core/OF
1575 : OF \ #of-1 -- orgOF #of
1577 >R \ move off the stack in case the control-flow stack is the data stack.
1578 POSTPONE OVER POSTPONE = \ copy and test case value
1579 POSTPONE IF \ add orig to control flow stack
1580 POSTPONE DROP \ discards case value if =
1581 R> \ we can bring count back now
1584 \ https://forth-standard.org/standard/core/ENDOF
1585 : ENDOF \ orgOF #of -- orgENDOF #of
1586 >R \ move off the stack in case the control-flow stack is the data stack.
1588 R> \ we can bring count back now
1591 \ https://forth-standard.org/standard/core/ENDCASE
1592 : ENDCASE \ orgENDOF1..orgENDOFn #of --
1605 ; CORE_ANS.f is loaded