1 \ ------------------------------------------------------------------------------
3 \ ------------------------------------------------------------------------------
5 \ must be preprocessed with yourtarget.pat file because PSTACK,CONTEXT,INI_THREAD:
7 \ TARGET SELECTION: selects to highlight target then CTRL+6
8 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
9 \ MSP_EXP430FR4133 MSP_EXP430FR2433 MSP_EXP430FR2355 CHIPSTICK_FR2433
11 \ ------------------------------------------------------------------------------
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, R7, R6, R5, R4
19 \ example : PUSHM IP,Y
21 \ POPM order : R4, R5, R6, R7, Y, X, W, T, S, IP,TOS,PSP
24 \ FORTH conditionnals: unary{ 0= 0< 0> }, binary{ = < > U< }
26 \ ASSEMBLER conditionnal usage with IF UNTIL WHILE S< S>= U< U>= 0= 0<> 0>=
28 \ ASSEMBLER conditionnal usage with ?JMP ?GOTO S< S>= U< U>= 0= 0<> <0
30 \ ------------------------------------------------------------------------------
33 [DEFINED] {TOOLS} [IF] {TOOLS} [THEN] \ remove {UTILITY} if outside core
35 [UNDEFINED] {TOOLS} [IF] \ don't replicate {UTILITY} if inside core
40 \ https://forth-standard.org/standard/tools/q
41 \ ? adr -- display the content of adr
50 \ https://forth-standard.org/standard/tools/DotS
51 \ .S -- display <depth> of param Stack and stack contents if not empty
53 MOV TOS,-2(PSP) \ -- TOS ( tos x x )
55 SUB #2,TOS \ to take count that TOS is first cell
56 MOV TOS,-6(PSP) \ -- TOS ( tos x PSP )
57 MOV #PSTACK,TOS \ -- P0 ( tos x PSP )
58 SUB #2,TOS \ to take count that TOS is first cell
59 BW1 MOV TOS,-4(PSP) \ -- S0 ( tos S0 SP )
60 SUB #6,PSP \ -- S0 SP S0
61 SUB @PSP,TOS \ -- S0 SP S0-SP
62 RRA TOS \ -- S0 SP #cells
67 $3E EMIT SPACE \ char '>' SPACE
79 [UNDEFINED] .RS [IF] \
80 \ .RS -- display <depth> of Return Stack and stack contents if not empty
82 MOV TOS,-2(PSP) \ -- TOS ( tos x x )
83 MOV RSP,-6(PSP) \ -- TOS ( tos x RSP )
84 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 \ \ vvvvvvvv may be skipped vvvvvvvv
120 \ 1 = IF DROP ." monothread"
122 \ THEN ." vocabularies"
124 \ \ ^^^^^^^^ may be skipped ^^^^^^^^
127 CONTEXT @ \ -- VOC_BODY MOVE all threads of VOC_BODY in PAD
128 PAD INI_THREAD @ DUP + \ -- VOC_BODY PAD THREAD*2
131 \ 0 DUP \ -- ptr=0 MAX=0 select the MAX of NFAs in all vocabulary threads
133 INI_THREAD @ DUP + 0 \ -- ptr=0 MAX=0 THREADS*2 0
134 DO \ -- ptr MAX I = PAD_ptr = thread*2
135 DUP I PAD + @ \ -- ptr MAX MAX NFAx
136 U< IF \ -- ptr MAX if MAX U< NFAx
137 DROP DROP \ -- drop ptr and MAX
138 I DUP PAD + @ \ -- new_ptr new_MAX
141 ?DUP \ -- ptr MAX MAX | -- ptr 0
142 WHILE \ -- ptr MAX replace it by its LFA
144 2 - @ \ -- ptr MAX [LFA]
145 ROT \ -- MAX [LFA] ptr
146 PAD + \ -- MAX [LFA] thread
147 ! \ -- MAX [LFA]=new_NFA --> PAD+ptr type it in 16 chars format
149 COUNT $7F AND \ -- MAX addr count (with suppr. of immediate bit)
151 C@ $0F AND \ -- count_of_chars
152 $10 SWAP - SPACES \ -- complete with spaces to 16 chars
159 [UNDEFINED] MAX [IF] \ MAX and MIN are defined in {ANS_COMP}
160 CODE MAX \ n1 n2 -- n3 signed maximum
168 CODE MIN \ n1 n2 -- n3 signed minimum
178 : U.R \ u n -- display u unsigned in n width (n >= 2)
180 R> OVER - 0 MAX SPACES TYPE
185 [UNDEFINED] DUMP [IF] \
186 \ https://forth-standard.org/standard/tools/DUMP
187 CODE DUMP \ adr n -- dump memory
189 PUSH &BASE \ save current base
190 MOV #$10,&BASE \ HEX base
191 ADD @PSP,TOS \ -- ORG END
193 SWAP OVER OVER \ -- END ORG END ORG
194 U. U. \ -- END ORG display org end
195 $FFF0 AND \ -- END ORG_modulo_16
196 DO CR \ generate line
197 I 7 U.R SPACE \ generate address
198 I $10 + I \ display 16 bytes
201 I $10 + I \ display 16 chars
202 DO I C@ $7E MIN BL MAX EMIT LOOP
204 R> BASE ! \ restore current base
219 : specs \ to see Fast Forth specifications
220 PWR_STATE \ remove specs definition when running, and before bytes free processing
221 6 0 DO BS LOOP \ 8 EMIT = BackSpace EMIT
222 ESC ." [7m" \ set reverse video
224 INI_THREAD @ U. ." Threads " \ vocabularies threads
225 FREQ_KHZ @ 0 1000 UM/MOD U. BS ." ," U. ." MHz " \ MCLK
226 HECTOBAUDS @ 0 10 UM/MOD U. BS ." ," U. ." kBds " \ Terminal Baudrate
227 FRAM_FULL HERE - U. ." bytes free"
228 ESC ." [0m" \ reset reverse video