2 ; ------------------------------------------------------------------------------
4 ; ------------------------------------------------------------------------------
6 \ to see kernel options, download FastForthSpecs.f
7 \ FastForth kernel options: MSP430ASSEMBLER, CONDCOMP
10 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
11 \ MSP_EXP430FR4133 MSP_EXP430FR2433 MSP_EXP430FR2355 CHIPSTICK_FR2433
14 \ R4 to R7 must be saved before use and restored after
15 \ scratch registers Y to S are free for use
16 \ under interrupt, IP is free for use
18 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, rEXIT,rDOVAR,rDOCON, rDODOES, R3, SR,RSP, PC
19 \ PUSHM order : R15,R14,R13,R12,R11,R10, R9, R8, R7 , R6 , R5 , R4 , R3, R2, R1, R0
21 \ example : PUSHM #6,IP pushes IP,S,T,W,X,Y registers to return stack
23 \ POPM order : PC,RSP, SR, R3, rDODOES,rDOCON,rDOVAR,rEXIT, Y, X, W, T, S, IP,TOS,PSP
24 \ POPM order : R0, R1, R2, R3, R4 , R5 , R6 , R7 , R8, R9,R10,R11,R12,R13,R14,R15
26 \ example : POPM #6,IP pop 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 ?JMP ?GOTO S< S>= U< U>= 0= 0<> 0<
36 [DEFINED] {TOOLS} [IF] {TOOLS} [THEN] \ remove {UTILITY} if outside core
38 [UNDEFINED] {TOOLS} [IF] \ don't replicate {UTILITY} if inside core
43 \ https://forth-standard.org/standard/tools/q
44 \ ? adr -- display the content of adr
52 \ https://forth-standard.org/standard/tools/DotS
53 \ .S -- display <depth> of param Stack and stack contents if not empty
55 MOV TOS,-2(PSP) \ -- TOS ( tos x x )
57 SUB #2,TOS \ to take count that TOS is first cell
58 MOV TOS,-6(PSP) \ -- TOS ( tos x PSP )
59 MOV #PSTACK,TOS \ -- P0 ( tos x PSP )
60 SUB #2,TOS \ to take count that TOS is first cell
61 BW1 MOV TOS,-4(PSP) \ -- S0 ( tos S0 SP )
62 SUB #6,PSP \ -- S0 SP S0
63 SUB @PSP,TOS \ -- S0 SP S0-SP
64 RRA TOS \ -- S0 SP #cells
69 $3E EMIT SPACE \ char '>' SPACE
80 [UNDEFINED] .RS [IF] \
81 \ .RS -- display <depth> of Return Stack and stack contents if not empty
83 MOV TOS,-2(PSP) \ -- TOS ( tos x x )
84 MOV RSP,-6(PSP) \ -- TOS ( tos x RSP )
85 MOV #RSTACK,TOS \ -- R0 ( tos x RSP )
90 [UNDEFINED] WORDS [IF]
94 \ https://forth-standard.org/standard/core/AND
95 \ C AND x1 x2 -- x3 logical AND
105 \ https://forth-standard.org/standard/core/PAD
111 \ https://forth-standard.org/standard/tools/WORDS
112 \ list all words of vocabulary first in CONTEXT.
115 CONTEXT @ \ -- VOC_BODY MOVE all threads of VOC_BODY in PAD
116 PAD INI_THREAD @ DUP + \ -- VOC_BODY PAD THREAD*2
120 INI_THREAD @ DUP + 0 \ -- ptr=0 MAX=0 THREADS*2 0
121 DO \ -- ptr MAX I = PAD_ptr = thread*2
122 DUP I PAD + @ \ -- ptr MAX MAX NFAx
123 U< IF \ -- ptr MAX if MAX U< NFAx
124 DROP DROP \ -- drop ptr and MAX
125 I DUP PAD + @ \ -- new_ptr new_MAX
128 ?DUP \ -- ptr MAX MAX | -- ptr 0
129 WHILE \ -- ptr MAX replace it by its LFA
131 2 - @ \ -- ptr MAX [LFA]
132 ROT \ -- MAX [LFA] ptr
133 PAD + \ -- MAX [LFA] thread
134 ! \ -- MAX [LFA]=new_NFA --> PAD+ptr type it in 16 chars format
136 COUNT $7F AND \ -- MAX addr count (with suppr. of immediate bit)
138 C@ $0F AND \ -- count_of_chars
139 $10 SWAP - SPACES \ -- complete with spaces modulo 16 chars
145 [UNDEFINED] MAX [IF] \ MAX and MIN are defined in {ANS_COMP}
146 CODE MAX \ n1 n2 -- n3 signed maximum
154 CODE MIN \ n1 n2 -- n3 signed minimum
163 : U.R \ u n -- display u unsigned in n width (n >= 2)
165 R> OVER - 0 MAX SPACES TYPE
169 [UNDEFINED] DUMP [IF] \
170 \ https://forth-standard.org/standard/tools/DUMP
171 CODE DUMP \ adr n -- dump memory
173 PUSH &BASE \ save current base
174 MOV #$10,&BASE \ HEX base
175 ADD @PSP,TOS \ -- ORG END
177 SWAP OVER OVER \ -- END ORG END ORG
178 U. U. \ -- END ORG display org end
179 $FFF0 AND \ -- END ORG_modulo_16
180 DO CR \ generate line
181 I 7 U.R SPACE \ generate address
182 I $10 + I \ display 16 bytes
185 I $10 + I \ display 16 chars
186 DO I C@ $7E MIN BL MAX EMIT LOOP
188 R> BASE ! \ restore current base
190 [THEN] \ of [UNDEFINED] DUMP
197 [THEN] \ of [UNDEFINED] {TOOLS}