1 \ -*- coding: utf-8 -*-
3 ; ------------------------------------------------------------------------------
5 ; ------------------------------------------------------------------------------
7 \ to see kernel options, download FastForthSpecs.f
8 \ FastForth kernel options: MSP430ASSEMBLER, CONDCOMP
11 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
12 \ MSP_EXP430FR4133 MSP_EXP430FR2433 MSP_EXP430FR2355 CHIPSTICK_FR2433
15 \ R4 to R7 must be saved before use and restored after
16 \ scratch registers Y to S are free for use
17 \ under interrupt, IP is free for use
19 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, rEXIT,rDOVAR,rDOCON, rDODOES, R3, SR,RSP, PC
20 \ PUSHM order : R15,R14,R13,R12,R11,R10, R9, R8, R7 , R6 , R5 , R4 , R3, R2, R1, R0
22 \ example : PUSHM #6,IP pushes IP,S,T,W,X,Y registers to return stack
24 \ POPM order : PC,RSP, SR, R3, rDODOES,rDOCON,rDOVAR,rEXIT, Y, X, W, T, S, IP,TOS,PSP
25 \ POPM order : R0, R1, R2, R3, R4 , R5 , R6 , R7 , R8, R9,R10,R11,R12,R13,R14,R15
27 \ example : POPM #6,IP pop 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 ?JMP ?GOTO S< S>= U< U>= 0= 0<> 0<
36 : DEFINED! ECHO 1 ABORT" already loaded!" ;
38 [DEFINED] {TOOLS} [IF] DEFINED!
47 \ https://forth-standard.org/standard/tools/q
48 \ ? adr -- display the content of adr
56 \ https://forth-standard.org/standard/tools/DotS
57 \ .S -- display <depth> of param Stack and stack contents in hedadecimal if not empty
59 MOV TOS,-2(PSP) \ -- TOS ( tos x x )
61 SUB #2,TOS \ to take count that TOS is first cell
62 MOV TOS,-6(PSP) \ -- TOS ( tos x PSP )
63 MOV #PSTACK,TOS \ -- P0 ( tos x PSP )
64 SUB #2,TOS \ to take count that TOS is first cell
65 BW1 MOV TOS,-4(PSP) \ -- S0 ( tos S0 SP )
66 SUB #6,PSP \ -- S0 SP S0
67 SUB @PSP,TOS \ -- S0 SP S0-SP
68 RRA TOS \ -- S0 SP #cells
73 $3E EMIT SPACE \ char '>' SPACE
77 THEN \ display content of stack in hexadecimal
87 [UNDEFINED] .RS [IF] \
88 \ .RS -- display <depth> of Return Stack and stack contents if not empty
90 MOV TOS,-2(PSP) \ -- TOS ( tos x x )
91 MOV RSP,-6(PSP) \ -- TOS ( tos x RSP )
92 MOV #RSTACK,TOS \ -- R0 ( tos x RSP )
99 \ https://forth-standard.org/standard/core/AND
100 \ C AND x1 x2 -- x3 logical AND
110 \ https://forth-standard.org/standard/core/PAD
117 [UNDEFINED] WORDS [IF]
118 \ https://forth-standard.org/standard/tools/WORDS
119 \ list all words of vocabulary first in CONTEXT.
122 CONTEXT @ PAD \ -- VOC_BODY PAD MOVE all threads of VOC_BODY in PAD
123 INI_THREAD @ DUP + \ -- VOC_BODY PAD THREAD*2
124 MOVE \ -- vocabumary entries are copied in PAD
126 0 DUP \ -- ptr=0 MAX=0
127 INI_THREAD @ DUP + 0 \ -- ptr=0 MAX=0 THREADS*2 0
128 DO \ -- ptr MAX I = PAD_ptr = thread*2
129 DUP I PAD + @ \ -- ptr MAX MAX NFAx
130 U< IF \ -- ptr MAX if MAX U< NFAx
131 DROP DROP \ -- drop ptr and MAX
132 I DUP PAD + @ \ -- new_ptr new_MAX
135 ?DUP \ -- ptr MAX MAX | -- ptr 0 (all threads in PAD = 0)
136 WHILE \ -- ptr MAX replace it by its LFA
138 2 - @ \ -- ptr MAX [LFA]
139 ROT \ -- MAX [LFA] ptr
140 PAD + \ -- MAX [LFA] thread
141 ! \ -- MAX [LFA]=new_NFA updates PAD+ptr
143 COUNT $7F AND \ -- MAX addr count (with suppr. of immediate bit)
145 C@ $0F AND \ -- count_of_chars
146 $10 SWAP - SPACES \ -- complete with spaces modulo 16 chars
149 ; \ all threads in PAD are filled with 0
152 [UNDEFINED] MAX [IF] \ MAX and MIN are defined in {ANS_COMP}
153 CODE MAX \ n1 n2 -- n3 signed maximum
160 CODE MIN \ n1 n2 -- n3 signed minimum
169 : U.R \ u n -- display u unsigned in n width (n >= 2)
171 R> OVER - 0 MAX SPACES TYPE
175 [UNDEFINED] DUMP [IF] \
176 \ https://forth-standard.org/standard/tools/DUMP
177 CODE DUMP \ adr n -- dump memory
179 PUSH &BASE \ save current base
180 MOV #$10,&BASE \ HEX base
181 ADD @PSP,TOS \ -- ORG END
183 SWAP OVER OVER \ -- END ORG END ORG
184 U. U. \ -- END ORG display org end
185 $FFF0 AND \ -- END ORG_modulo_16
186 DO CR \ generate line
187 I 4 U.R SPACE \ generate address
188 I 8 + I \ display first 8 bytes
191 I $10 + I 8 + \ display last 8 bytes
194 I $10 + I \ display 16 chars
195 DO I C@ $7E MIN BL MAX EMIT LOOP
197 R> BASE ! \ restore current base
199 [THEN] \ endof [UNDEFINED] DUMP
203 [THEN] \ endof [UNDEFINED] {TOOLS}