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
8 \ from scite editor : copy your target selection in (shift+F8) parameter 1:
12 \ drag and drop this file onto SendSourceFileToTarget.bat
13 \ then select your TARGET when asked.
17 \ rDODOES to rEXIT must be saved before use and restored after
18 \ scratch registers Y to S are free for use
19 \ under interrupt, IP is free for use
21 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, rEXIT, rDOVAR, rDOCON, rDODOES
22 \ example : PUSHM #6,IP pushes IP,S,T,W,X,Y registers to return stack
24 \ POPM order : rDODOES, rDOCON, rDOVAR, rEXIT, Y, X, W, T, S, IP,TOS,PSP
25 \ example : POPM #6,IP pulls Y,X,W,T,S,IP registers from return stack
27 \ FORTH conditionnals: unary{ 0= 0< 0> }, binary{ = < > U< }
29 \ ASSEMBLER conditionnal usage with IF UNTIL WHILE S< S>= U< U>= 0= 0<> 0>=
30 \ ASSEMBLER conditionnal usage with ?GOTO S< S>= U< U>= 0= 0<> 0<
36 SUB #309,TOS \ FastForth V3.9
38 $0D EMIT \ return to column 1 without CR
39 ABORT" FastForth V3.9 please!"
44 \ BC! pattern @ -- Bits Clear in @
54 \ BS! pattern @ -- Bits Set in @
64 \ =============================================================================
65 \ $8000 KERNEL_ADDON BS! \ uncomment to select FLOORED division
66 $8000 KERNEL_ADDON BC! \ uncomment to select SYMMETRIC division
67 \ =============================================================================
69 RST_RET \ remove all above before CORE_ANS downloading
71 ; ----------------------------------
73 ; ----------------------------------
75 \ words complement to pass CORETEST.4TH
77 MARKER {CORE_ANS} \ if already defined removes it before.
86 \ https://forth-standard.org/standard/core/Plus
87 \ + n1/u1 n2/u2 -- n3/u3 add n1+n2
96 \ https://forth-standard.org/standard/core/Minus
97 \ - n1/u1 n2/u2 -- n3/u3 n3 = n1-n2
101 SUB @PSP+,TOS \ 2 -- n2-n1 ( = -n3)
103 ADD #1,TOS \ 1 -- n3 = -(n2-n1) = n1-n2
108 \ https://forth-standard.org/standard/core/DUP
109 \ DUP x -- x x duplicate top of stack
113 BW1 SUB #2,PSP \ 2 push old TOS..
114 MOV TOS,0(PSP) \ 3 ..onto stack
118 \ https://forth-standard.org/standard/core/qDUP
119 \ ?DUP x -- 0 | x x DUP if nonzero
121 CMP #0,TOS \ 2 test for TOS nonzero
127 \ https://forth-standard.org/standard/core/EXIT
128 \ EXIT -- exit a colon definition
132 MOV @RSP+,IP \ 2 pop previous IP (or next PC) from return stack
133 MOV @IP+,PC \ 4 = NEXT
137 \ https://forth-standard.org/standard/core/DEPTH
138 \ DEPTH -- +n number of items on stack, must leave 0 if stack empty
144 SUB PSP,TOS \ PSP-S0--> TOS
145 RRA TOS \ TOS/2 --> TOS
146 SUB #2,PSP \ post decrement stack...
151 \ https://forth-standard.org/standard/core/SWAP
152 \ SWAP x1 x2 -- x2 x1 swap top two items
163 \ https://forth-standard.org/standard/core/DROP
164 \ DROP x -- drop top of stack
173 \ https://forth-standard.org/standard/core/OVER
174 \ OVER x1 x2 -- x1 x2 x1
178 MOV TOS,-2(PSP) \ 3 -- x1 (x2) x2
179 MOV @PSP,TOS \ 2 -- x1 (x2) x1
180 SUB #2,PSP \ 1 -- x1 x2 x1
185 \ https://forth-standard.org/standard/core/NIP
186 \ NIP x1 x2 -- x2 Drop the first item below the top of stack
195 \ https://forth-standard.org/standard/core/toR
196 \ >R x -- R: -- x push to return stack
206 \ https://forth-standard.org/standard/core/Rfrom
207 \ R> -- x R: x -- pop from return stack
218 \ https://forth-standard.org/standard/core/Fetch
219 \ @ c-addr -- word fetch word from memory
228 \ https://forth-standard.org/standard/core/Store
229 \ ! word c-addr -- store word in memory
239 \ https://forth-standard.org/standard/core/Fetch
240 \ C@ c-addr -- char fetch char from memory
249 \ https://forth-standard.org/standard/core/CStore
250 \ C! char c-addr -- store char in memory
254 MOV.B @PSP+,0(TOS) \ 4
261 \ https://forth-standard.org/standard/core/CComma
262 \ C, char -- append char
274 \ https://forth-standard.org/standard/core/ZeroEqual
275 \ 0= n/u -- flag return true if TOS=0
279 SUB #1,TOS \ 1 borrow (clear cy) if TOS was 0
280 SUBC TOS,TOS \ 1 TOS=-1 if borrow was set
285 \ https://forth-standard.org/standard/core/Zerone
286 \ 0<> n/u -- flag return true if TOS<>0
290 SUB #1,TOS \ 1 borrow (clear cy) if TOS was 0
291 SUBC TOS,TOS \ 1 TOS=-1 if borrow was set
297 \ https://forth-standard.org/standard/core/Zeroless
298 \ 0< n -- flag true if TOS negative
302 BW1 ADD TOS,TOS \ 1 set carry if TOS negative
303 SUBC TOS,TOS \ 1 TOS=-1 if carry was clear
304 XOR #-1,TOS \ 1 TOS=-1 if carry was set
311 \ https://forth-standard.org/standard/core/StoD
312 \ S>D n -- d single -> double prec.
320 \ https://forth-standard.org/standard/core/Equal
321 \ = x1 x2 -- flag test x1=x2
326 SUB #1,TOS \ 1 borrow (clear cy) if TOS was 0
327 SUBC TOS,TOS \ 1 TOS=-1 if borrow was set
332 \ https://forth-standard.org/standard/core/Uless
333 \ U< u1 u2 -- flag test u1<u2, unsigned
338 SUB @PSP+,TOS \ 2 u2-u1
346 \ https://forth-standard.org/standard/core/Umore
350 U< ?GOTO BW1 \ 2 flag = true, Z = 0
351 FW1 AND #0,TOS \ 1 Z = 1
356 \ https://forth-standard.org/standard/core/less
357 \ < n1 n2 -- flag test n1<n2, signed
359 [IF] \ define < and >
362 SUB @PSP+,TOS \ 1 TOS=n2-n1
363 S< ?GOTO FW1 \ 2 signed
365 BW1 MOV #-1,TOS \ 1 flag Z = 0
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 BW1 \ 2 --> +5
375 FW1 AND #0,TOS \ 1 flag Z = 1
380 \ ------------------------------------------------------------------------------
382 \ ------------------------------------------------------------------------------
383 \ THEN and BEGIN compile nothing
384 \ DO compile one word
385 \ IF, ELSE, AGAIN, UNTIL, WHILE, REPEAT, LOOP & +LOOP compile two words
386 \ LEAVE compile three words
388 \ https://forth-standard.org/standard/core/IF
389 \ IF -- IFadr initialize conditional forward branch
391 [IF] \ define IF THEN
396 MOV &DP,TOS \ -- HERE
397 ADD #4,&DP \ compile one word, reserve one word
398 MOV #QFBRAN,0(TOS) \ -- HERE compile QFBRAN
399 ADD #2,TOS \ -- HERE+2=IFadr
403 \ https://forth-standard.org/standard/core/THEN
404 \ THEN IFadr -- resolve forward branch
406 MOV &DP,0(TOS) \ -- IFadr
412 \ https://forth-standard.org/standard/core/ELSE
413 \ ELSE IFadr -- ELSEadr resolve forward IF branch, leave ELSEadr on stack
417 ADD #4,&DP \ make room to compile two words
420 MOV W,0(TOS) \ HERE+4 ==> [IFadr]
422 MOV W,TOS \ -- ELSEadr
427 \ https://forth-standard.org/standard/core/BEGIN
428 \ BEGIN -- BEGINadr initialize backward branch
430 [IF] \ define BEGIN UNTIL AGAIN WHILE REPEAT
436 \ https://forth-standard.org/standard/core/UNTIL
437 \ UNTIL BEGINadr -- resolve conditional backward branch
440 BW1 ADD #4,&DP \ compile two words
442 MOV X,-4(W) \ compile Bran or QFBRAN at HERE
443 MOV TOS,-2(W) \ compile bakcward adr at HERE+2
448 \ https://forth-standard.org/standard/core/AGAIN
449 \ AGAIN BEGINadr -- resolve uncondionnal backward branch
455 \ https://forth-standard.org/standard/core/WHILE
456 \ WHILE BEGINadr -- WHILEadr BEGINadr
461 \ https://forth-standard.org/standard/core/REPEAT
462 \ REPEAT WHILEadr BEGINadr -- resolve WHILE loop
464 POSTPONE AGAIN POSTPONE THEN
469 [IF] \ define DO LOOP +LOOP
471 \ https://forth-standard.org/standard/core/DO
472 \ DO -- DOadr L: -- 0
473 HDNCODE XDO \ DO run time
474 MOV #$8000,X \ 2 compute 8000h-limit = "fudge factor"
476 MOV TOS,Y \ 1 loop ctr = index+fudge
477 ADD X,Y \ 1 Y = INDEX
478 PUSHM #2,X \ 4 PUSHM X,Y, i.e. PUSHM LIMIT, INDEX
486 ADD #2,&DP \ make room to compile xdo
487 MOV &DP,TOS \ -- HERE+2
488 MOV #XDO,-2(TOS) \ compile xdo
489 ADD #2,&LEAVEPTR \ -- HERE+2 LEAVEPTR+2
491 MOV #0,0(W) \ -- HERE+2 L-- 0, init
495 \ https://forth-standard.org/standard/core/LOOP
496 \ LOOP DOadr -- L-- an an-1 .. a1 0
497 HDNCODE XLOOP \ LOOP run time
498 ADD #1,0(RSP) \ 4 increment INDEX
499 BW1 BIT #$100,SR \ 2 is overflow bit set?
500 0= IF \ branch if no overflow
504 ADD #4,RSP \ 1 empties RSP
505 ADD #2,IP \ 1 overflow = loop done, skip branch ofs
506 MOV @IP+,PC \ 4 14~ taken or not taken xloop/loop
511 BW2 ADD #4,&DP \ make room to compile two words
513 MOV X,-4(W) \ xloop --> HERE
514 MOV TOS,-2(W) \ DOadr --> HERE+2
515 BEGIN \ resolve all "leave" adr
516 MOV &LEAVEPTR,TOS \ -- Adr of top LeaveStack cell
517 SUB #2,&LEAVEPTR \ --
518 MOV @TOS,TOS \ -- first LeaveStack value
519 CMP #0,TOS \ -- = value left by DO ?
521 MOV W,0(TOS) \ move adr after loop as UNLOOP adr
527 \ https://forth-standard.org/standard/core/PlusLOOP
528 \ +LOOP adrs -- L-- an an-1 .. a1 0
529 HDNCODE XPLOO \ +LOOP run time
530 ADD TOS,0(RSP) \ 4 increment INDEX by TOS value
531 MOV @PSP+,TOS \ 2 get new TOS, doesn't change flags
541 \ https://forth-standard.org/standard/core/I
542 \ I -- n R: sys1 sys2 -- sys1 sys2
543 \ get the innermost loop index
547 SUB #2,PSP \ 1 make room in TOS
549 MOV @RSP,TOS \ 2 index = loopctr - fudge
555 \ https://forth-standard.org/standard/core/J
556 \ J -- n R: 4*sys -- 4*sys
557 \ C get the second loop index
569 \ https://forth-standard.org/standard/core/UNLOOP
570 \ UNLOOP -- R: sys1 sys2 -- drop loop parms
579 \ https://forth-standard.org/standard/core/LEAVE
580 \ LEAVE -- L: -- adrs
584 MOV &DP,W \ compile three words
585 MOV #UNLOOP,0(W) \ [HERE] = UNLOOP
586 MOV #BRAN,2(W) \ [HERE+2] = BRAN
587 ADD #6,&DP \ [HERE+4] = at adr After LOOP
591 MOV W,0(X) \ leave HERE+4 on LEAVEPTR stack
596 \ https://forth-standard.org/standard/core/AND
597 \ C AND x1 x2 -- x3 logical AND
606 \ https://forth-standard.org/standard/core/OR
607 \ C OR x1 x2 -- x3 logical OR (BIS, BIts Set)
612 AND #-1,TOS \ to set flags
617 \ https://forth-standard.org/standard/core/XOR
618 \ C XOR x1 x2 -- x3 logical XOR
627 \ https://forth-standard.org/standard/core/OnePlus
628 \ 1+ n1/u1 -- n2/u2 add 1 to TOS
637 \ https://forth-standard.org/standard/core/OneMinus
638 \ 1- n1/u1 -- n2/u2 subtract 1 from TOS
647 \ https://forth-standard.org/standard/core/INVERT
648 \ INVERT x1 -- x2 bitwise inversion
657 \ https://forth-standard.org/standard/core/NEGATE
658 \ C NEGATE x1 -- x2 two's complement
668 \ https://forth-standard.org/standard/core/ABS
669 \ C ABS n1 -- +n2 absolute value
681 \ https://forth-standard.org/standard/core/LSHIFT
682 \ LSHIFT x1 u -- x2 logical L shift u places
687 AND #$1F,TOS \ no need to shift more than 16
699 \ https://forth-standard.org/standard/core/RSHIFT
700 \ RSHIFT x1 u -- x2 logical R7 shift u places
705 AND #$1F,TOS \ no need to shift more than 16
708 BIC #C,SR \ Clr Carry
718 \ https://forth-standard.org/standard/core/MAX
719 \ MAX n1 n2 -- n3 signed maximum
730 \ https://forth-standard.org/standard/core/MIN
731 \ MIN n1 n2 -- n3 signed minimum
740 \ https://forth-standard.org/standard/core/TwoTimes
741 \ 2* x1 -- x2 arithmetic left shift
750 \ https://forth-standard.org/standard/core/TwoDiv
751 \ 2/ x1 -- x2 arithmetic right shift
760 \ --------------------
761 \ ARITHMETIC OPERATORS
762 \ --------------------
765 CODE TSTBIT \ addr bit_mask -- true/flase flag
771 \ $81EF DEVICEID @ U<
772 \ DEVICEID @ $81F3 U<
773 \ = [IF] ; MSP430FR413x subfamily without hardware_MPY
774 KERNEL_ADDON HMPY TSTBIT \ KERNEL_ADDON(BIT0) = hardware MPY flag
778 \ https://forth-standard.org/standard/core/MTimes
779 \ M* n1 n2 -- dlo dhi signed 16*16->32 multiply
781 MOV @PSP,&MPY \ Load 1st operand for unsigned multiplication
782 BW1 MOV TOS,&OP2 \ Load 2nd operand
783 MOV &RES0,0(PSP) \ low result on stack
784 MOV &RES1,TOS \ high result in TOS
788 \ https://forth-standard.org/standard/core/MTimes
789 \ M* n1 n2 -- dlo dhi signed 16*16->32 multiply
791 MOV @PSP,&MPYS \ Load 1st operand for signed multiplication
795 [ELSE] ; MSP430FRxxxx with hardware_MPY
796 \ https://forth-standard.org/standard/core/UMTimes
797 \ UM* u1 u2 -- udlo udhi unsigned 16x16->32 mult.
803 XOR #-1,0(PSP) \ n1 --> u1
806 XOR TOS,S \ S contains sign of result
807 CMP #0,TOS \ n2 > -1 ?
809 XOR #-1,TOS \ n2 --> u2
812 PUSHM #2,IP \ UMSTAR use S,T,W,X,Y
816 POPM #2,IP \ pop S,IP
817 CMP #0,S \ sign of result > -1 ?
819 XOR #-1,0(PSP) \ ud --> d
827 [THEN] ; endof hardware_MPY
831 \ https://forth-standard.org/standard/core/UMDivMOD
832 \ UM/MOD udlo|udhi u1 -- r q unsigned 32/16->r16 q16
837 MOV #MUSMOD,PC \ execute MUSMOD then return to DROP
844 KERNEL_ADDON @ 0< ; test the switch: FLOORED / SYMETRIC DIVISION
846 \ https://forth-standard.org/standard/core/FMDivMOD
847 \ FM/MOD d1 n1 -- r q floored signed div'n
853 CMP #0,TOS \ n2 >= 0 ?
856 ADD #1,TOS \ -- d1 u2
858 CMP #0,0(PSP) \ d1hi >= 0 ?
860 XOR #-1,2(PSP) \ d1lo
861 XOR #-1,0(PSP) \ d1hi
862 ADD #1,2(PSP) \ d1lo+1
863 ADDC #0,0(PSP) \ d1hi+C
864 THEN \ -- uDVDlo uDVDhi uDIVlo
865 PUSHM #2,S \ 4 PUSHM S,T
868 POPM #2,S \ 4 POPM T,S
869 CMP #0,T \ T=DVDhi --> REM_sign
874 XOR S,T \ S=DIV XOR T=DVDhi = Quot_sign
875 CMP #0,T \ -- n3 u4 T=quot_sign
879 THEN \ -- n3 n4 S=divisor
881 CMP #0,0(PSP) \ remainder <> 0 ?
883 CMP #1,TOS \ quotient < 1 ?
885 ADD S,0(PSP) \ add divisor to remainder
886 SUB #1,TOS \ decrement quotient
893 \ https://forth-standard.org/standard/core/SMDivREM
894 \ SM/REM DVDlo DVDhi DIV -- r3 q4 symmetric signed div
900 CMP #0,TOS \ n2 >= 0 ?
903 ADD #1,TOS \ -- d1 u2
905 CMP #0,0(PSP) \ d1hi >= 0 ?
907 XOR #-1,2(PSP) \ d1lo
908 XOR #-1,0(PSP) \ d1hi
909 ADD #1,2(PSP) \ d1lo+1
910 ADDC #0,0(PSP) \ d1hi+C
911 THEN \ -- uDVDlo uDVDhi uDIVlo
912 PUSHM #2,S \ 4 PUSHM S,T
915 POPM #2,S \ 4 POPM T,S
916 CMP #0,T \ T=DVDhi --> REM_sign
921 XOR S,T \ S=DIV XOR T=DVDhi = Quot_sign
922 CMP #0,T \ -- n3 u4 T=quot_sign
926 THEN \ -- n3 n4 S=divisor
932 \ https://forth-standard.org/standard/core/Times
933 \ * n1 n2 -- n3 signed multiply
941 \ https://forth-standard.org/standard/core/DivMOD
942 \ /MOD n1 n2 -- r3 q4 signed division
947 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
954 \ https://forth-standard.org/standard/core/Div
955 \ / n1 n2 -- n3 signed quotient
960 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
968 \ https://forth-standard.org/standard/core/MOD
969 \ MOD n1 n2 -- n3 signed remainder
974 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
982 \ https://forth-standard.org/standard/core/TimesDivMOD
983 \ */MOD n1 n2 n3 -- r4 q5 signed mult/div
988 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
995 \ https://forth-standard.org/standard/core/TimesDiv
996 \ */ n1 n2 n3 -- n4 n1*n2/q3
1001 [ KERNEL_ADDON @ 0< ] \ test the switch: FLOORED / SYMETRIC DIVISION
1009 \ -------------------------------------------------------------------------------
1011 \ -------------------------------------------------------------------------------
1012 \ https://forth-standard.org/standard/core/ROT
1013 \ ROT x1 x2 x3 -- x2 x3 x1
1017 MOV @PSP,W \ 2 fetch x2
1018 MOV TOS,0(PSP) \ 3 store x3
1019 MOV 2(PSP),TOS \ 3 fetch x1
1020 MOV W,2(PSP) \ 3 store x2
1025 \ https://forth-standard.org/standard/core/RFetch
1026 \ R@ -- x R: x -- x fetch from return stack
1037 \ https://forth-standard.org/standard/core/TUCK
1038 \ TUCK ( x1 x2 -- x2 x1 x2 )
1044 \ ----------------------------------------------------------------------
1046 \ ----------------------------------------------------------------------
1047 \ https://forth-standard.org/standard/core/TwoFetch
1048 \ 2@ a-addr -- x1 x2 fetch 2 cells ; the lower address will appear on top of stack
1059 \ https://forth-standard.org/standard/core/TwoStore
1060 \ 2! x1 x2 a-addr -- store 2 cells ; the top of stack is stored at the lower adr
1071 \ https://forth-standard.org/standard/core/TwoDUP
1072 \ 2DUP x1 x2 -- x1 x2 x1 x2 dup top 2 cells
1077 MOV @PSP,-4(PSP) \ 4
1083 \ https://forth-standard.org/standard/core/TwoDROP
1084 \ 2DROP x1 x2 -- drop 2 cells
1094 \ https://forth-standard.org/standard/core/TwoSWAP
1095 \ 2SWAP x1 x2 x3 x4 -- x3 x4 x1 x2
1099 MOV @PSP,W \ -- x1 x2 x3 x4 W=x3
1100 MOV 4(PSP),0(PSP) \ -- x1 x2 x1 x4
1101 MOV W,4(PSP) \ -- x3 x2 x1 x4
1102 MOV TOS,W \ -- x3 x2 x1 x4 W=x4
1103 MOV 2(PSP),TOS \ -- x3 x2 x1 x2 W=x4
1104 MOV W,2(PSP) \ -- x3 x4 x1 x2
1109 \ https://forth-standard.org/standard/core/TwoOVER
1110 \ 2OVER x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2
1114 SUB #4,PSP \ -- x1 x2 x3 x x x4
1115 MOV TOS,2(PSP) \ -- x1 x2 x3 x4 x x4
1116 MOV 8(PSP),0(PSP) \ -- x1 x2 x3 x4 x1 x4
1117 MOV 6(PSP),TOS \ -- x1 x2 x3 x4 x1 x2
1122 \ ----------------------------------------------------------------------
1123 \ ALIGNMENT OPERATORS
1124 \ ----------------------------------------------------------------------
1125 \ https://forth-standard.org/standard/core/ALIGNED
1126 \ ALIGNED addr -- a-addr align given addr
1136 \ https://forth-standard.org/standard/core/ALIGN
1137 \ ALIGN -- align HERE
1147 \ ---------------------
1148 \ PORTABILITY OPERATORS
1149 \ ---------------------
1150 \ https://forth-standard.org/standard/core/CHARS
1151 \ CHARS n1 -- n2 chars->adrs units
1159 \ https://forth-standard.org/standard/core/CHARPlus
1160 \ CHAR+ c-addr1 -- c-addr2 add char size
1169 \ https://forth-standard.org/standard/core/CELLS
1170 \ CELLS n1 -- n2 cells->adrs units
1179 \ https://forth-standard.org/standard/core/CELLPlus
1180 \ CELL+ a-addr1 -- a-addr2 add cell size
1189 \ ---------------------------
1190 \ BLOCK AND STRING COMPLEMENT
1191 \ ---------------------------
1192 \ https://forth-standard.org/standard/core/CHAR
1193 \ CHAR -- char parse ASCII character
1201 \ https://forth-standard.org/standard/core/BracketCHAR
1202 \ [CHAR] -- compile character literal
1206 CHAR POSTPONE LITERAL
1210 \ https://forth-standard.org/standard/core/PlusStore
1211 \ +! n/u a-addr -- add n/u to memory
1221 \ https://forth-standard.org/standard/core/MOVE
1222 \ MOVE addr1 addr2 u -- smart move
1223 \ VERSION FOR 1 ADDRESS UNIT = 1 CHAR
1228 MOV @PSP+,Y \ Y = addr2 = dst
1229 MOV @PSP+,X \ X = addr1 = src
1230 MOV @PSP+,TOS \ pop new TOS
1231 CMP #0,W \ count = 0 ?
1232 0<> IF \ if 0, already done !
1233 CMP X,Y \ dst = src ?
1234 0<> IF \ if 0, already done !
1235 U< IF \ U< if src > dst
1236 BEGIN \ copy W bytes
1241 MOV @IP+,PC \ out 1 of MOVE ====>
1242 THEN \ U>= if dst > src
1243 ADD W,Y \ copy W bytes beginning with the end
1253 MOV @IP+,PC \ out 2 of MOVE ====>
1257 \ https://forth-standard.org/standard/core/FILL
1258 \ FILL c-addr u char -- fill memory with char
1263 MOV @PSP+,W \ address
1267 MOV.B TOS,0(W) \ store char in memory
1272 MOV @PSP+,TOS \ empties stack
1277 \ --------------------
1278 \ INTERPRET COMPLEMENT
1279 \ --------------------
1280 \ https://forth-standard.org/standard/core/HEX
1289 \ https://forth-standard.org/standard/core/DECIMAL
1298 \ https://forth-standard.org/standard/core/p
1299 \ ( -- skip input until char ) or EOL
1307 \ https://forth-standard.org/standard/core/Dotp
1308 \ .( -- type comment immediatly.
1312 MOV #0,&CAPS \ CAPS OFF
1317 MOV #$20,&CAPS \ CAPS ON
1323 \ https://forth-standard.org/standard/core/toBODY
1324 \ >BODY -- addr leave BODY of a CREATEd word\ also leave default ACTION-OF primary DEFERred word
1333 \ https://forth-standard.org/standard/core/EXECUTE
1334 \ EXECUTE i*x xt -- j*x execute Forth word at 'xt'
1338 PUSH TOS \ 3 push xt
1340 MOV @RSP+,PC \ 4 xt --> PC
1344 \ https://forth-standard.org/standard/core/EVALUATE
1345 \ EVALUATE \ i*x c-addr u -- j*x interpret string
1346 [UNDEFINED] EVALUATE
1349 MOV #SOURCE_LEN,X \ 2
1350 MOV @X+,S \ 2 S = SOURCE_LEN
1351 MOV @X+,T \ 2 T = SOURCE_ORG
1352 MOV @X+,W \ 2 W = TOIN
1353 PUSHM #4,IP \ 6 PUSHM IP,S,T,W
1355 [ ' \ 8 + , ] \ compile INTERPRET
1358 MOV @RSP+,&SOURCE_ORG \ 4
1359 MOV @RSP+,&SOURCE_LEN \ 4
1365 \ https://forth-standard.org/standard/core/RECURSE
1366 \ C RECURSE -- recurse to current definition
1377 \ https://forth-standard.org/standard/core/SOURCE
1378 \ SOURCE -- adr u of current input buffer
1385 MOV &SOURCE_ORG,0(PSP)
1390 \ https://forth-standard.org/standard/core/VARIABLE
1391 \ VARIABLE <name> -- define a Forth VARIABLE
1392 [UNDEFINED] VARIABLE
1397 MOV #DOVAR,-4(W) \ CFA = CALL rDOVAR
1403 \ https://forth-standard.org/standard/core/CONSTANT
1404 \ CONSTANT <name> n -- define a Forth CONSTANT
1405 [UNDEFINED] CONSTANT
1410 MOV TOS,-2(W) \ PFA = n
1417 \ https://forth-standard.org/standard/core/STATE
1418 \ STATE -- a-addr holds compiler state
1421 STATEADR CONSTANT STATE
1424 \ https://forth-standard.org/standard/core/BASE
1425 \ BASE -- a-addr holds conversion radix
1428 BASEADR CONSTANT BASE
1431 \ https://forth-standard.org/standard/core/toIN
1432 \ C >IN -- a-addr holds offset in input stream
1438 \ https://forth-standard.org/standard/core/PAD
1442 PAD_ORG CONSTANT PAD
1445 \ https://forth-standard.org/standard/core/BL
1446 \ BL -- char an ASCII space
1452 \ https://forth-standard.org/standard/core/SPACE
1453 \ SPACE -- output a space
1460 \ https://forth-standard.org/standard/core/SPACES
1461 \ SPACES n -- output n spaces
1476 \ https://forth-standard.org/standard/core/DEFER
1477 \ Skip leading space delimiters. Parse name delimited by a space.
1478 \ Create a definition for name with the execution semantics defined below.
1480 \ name Execution: --
1481 \ Execute the xt that name is set to execute, i.e. NEXT (nothing),
1482 \ until the phrase ' word IS name is executed, causing a new value of xt to be assigned to name.
1486 MOV #$4030,-4(W) \4 first CELL = MOV @PC+,PC = BR #addr
1487 MOV #NEXT_ADR,-2(W) \3 second CELL = ...mNEXT : do nothing by default
1493 \ https://forth-standard.org/standard/core/CR
1494 \ CR -- send CR+LF to the output device
1497 \ DEFER CR \ DEFERed definition, by default executes :NONAME part
1498 CODE CR \ replaced by this CODE definition
1507 \ https://forth-standard.org/standard/core/TO
1508 \ TO name Run-time: ( x -- )
1509 \ Assign the value x to named VALUE.
1518 \ https://forth-standard.org/standard/core/VALUE
1519 \ ( x "<spaces>name" -- ) define a Forth VALUE
1520 \ Skip leading space delimiters. Parse name delimited by a space.
1521 \ Create a definition for name with the execution semantics defined below,
1522 \ with an initial value equal to x.
1524 \ name Execution: ( -- x )
1525 \ Place x on the stack. The value of x is that given when name was created,
1526 \ until the phrase x TO name is executed, causing a new value of x to be assigned to name.
1529 : VALUE \ x "<spaces>name" --
1534 BIT #UF9,SR \ 2 see TO
1535 0= IF \ 2 if UF9 is not set
1536 MOV @TOS,TOS \ 2 execute FETCH
1539 BIC #UF9,SR \ 2 clear UF9 flag
1540 MOV #!,PC \ 4 execute STORE
1544 \ https://forth-standard.org/standard/core/CASE
1549 ; IMMEDIATE \ -- #of-1
1551 \ https://forth-standard.org/standard/core/OF
1552 : OF \ #of-1 -- orgOF #of
1554 >R \ move off the stack in case the control-flow stack is the data stack.
1555 POSTPONE OVER POSTPONE = \ copy and test case value
1556 POSTPONE IF \ add orig to control flow stack
1557 POSTPONE DROP \ discards case value if =
1558 R> \ we can bring count back now
1561 \ https://forth-standard.org/standard/core/ENDOF
1562 : ENDOF \ orgOF #of -- orgENDOF #of
1563 >R \ move off the stack in case the control-flow stack is the data stack.
1565 R> \ we can bring count back now
1568 \ https://forth-standard.org/standard/core/ENDCASE
1569 : ENDCASE \ orgENDOF1..orgENDOFn #of --
1579 ; CORE_ANS.f is loaded