1 ;; Native x86 GNU/Linux Forth System, Direct Threaded Code
3 ;; Copyright (C) 2020 Ketmar Dark // Invisible Vector
5 ;; This program is free software: you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, version 3 of the License ONLY.
9 ;; This program is distributed in the hope that it will be useful,
10 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;; GNU General Public License for more details.
14 ;; You should have received a copy of the GNU General Public License
15 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 urword_code
"LITSTR",strlit
36 inc EIP ;; skip trailing zero
40 urword_code
"LITCFA",cfalit
49 urword_code
"LITCBLOCK",cblocklit
52 ; next cell is continue address
53 ; leave next next cell address as cfa
62 urword_code
"LITTO!",littopush
74 urword_code
"LIT+TO!",litaddtopush
86 urword_code
"LIT-TO!",litsubtopush
98 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
99 urword_code
"BRANCH",branch
107 urword_code
"0BRANCH",0branch
119 urword_code
"TBRANCH",tbranch
131 ;; branch if positive or zero
132 urword_code
"+0BRANCH",p0branch
144 ;; branch if negative or zero
145 urword_code
"-0BRANCH",m0branch
157 ;; branch if positive (not zero)
158 urword_code
"+BRANCH",pbranch
170 ;; branch if negative (not zero)
171 urword_code
"-BRANCH",mbranch
183 ;; used in "CASE": drops additional value if branch is NOT taken
184 urword_code
"0BRANCH-DROP",0branch_drop
194 ; branch not taken, drop one more data value
199 ;; if two values on the stack are equal, drop them, and take a branch
200 ;; if they aren't equal, do nothing
201 urword_code
"?DO-BRANCH",qdo_branch
207 ;; values are equal, drop them, and take a branch
216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
217 urword_code
"EXECUTE",execute
223 urword_code
"OVERRIDE-EXECUTE",override_execute
224 ;; ( ... xtoken -- ... )
232 urword_code
"(EXECUTE-INTR-CMPL)",par_execute_intr_cmpl
234 ;; ( intrcfa cmplcfa -- )
238 cp
dword [fvar_state_data
],0
245 urword_code
"EXIT",exit
251 urword_code
"0?EXIT",q0exit
262 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
263 urword_code
"(DO)",par_do
265 ;; ( limit start -- | limit counter )
266 ;; loops from start to limit-1
273 ld
[ERP
+4],edx ; 80000000h-to
274 ld
[ERP
],TOS
; 80000000h-to+from
279 urword_code
"(+LOOP)",par_ploop
281 ;; ( delta -- | limit counter )
298 urword_code
"(LOOP)",par_loop
300 urword_uses par_ploop
301 ;; ( -- | limit counter )
308 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
309 ;; as i moved high-level compiler out of the core, we should do it there
310 ;urword_alias "LEAVE",leave,break
313 urword_code
"UNLOOP",unloop
315 ;; ( | limit counter -- )
316 ;; removes loop arguments from return stack
317 ;; can be used as: UNLOOP EXIT
318 ;; "BREAK" compiles this word before branching out of the loop