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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 urword_code
"SP@",spget
25 urword_code
"RP@",rpget
31 urword_code
"SP!",spset
37 urword_code
"RP!",rpset
43 urword_code
"SP0!",spset0
44 mov esp,[fvar_sp0_data
]
49 urword_code
"RP0!",rpset0
50 mov ERP
,[fvar_rp0_data
]
54 urword_code
"(SP-CHECK)",par_spcheck
56 cmp eax,[fvar_sp0_data
]
58 mov esp,[fvar_sp0_data
]
69 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
70 urword_code
"RDUP",rdup
76 urword_code
"RDROP",rdrop
81 urword_code
">R",rpush
93 urword_code
"R@",rpeek
100 urword_code
"2RDROP",2rdrop
105 urword_code
"2>R",2rpush
106 ;; ( n0 n1 -- || -- n0 n1 )
114 urword_code
"2R>",2rpop
115 ;; ( -- n0 n1 || n0 n1 -- )
123 urword_code
"2R@",2rpeek
124 ;; ( -- n0 n1 || n0 n1 )
132 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
133 urword_code
"DUP",dup
138 urword_code
"2DUP",2dup
139 ;; ( n0 n1 -- n0 n1 n0 n1 )
148 urword_code
"?DUP",qdup
157 urword_code
"?DROP",qdrop
165 urword_code
"DROP",drop
170 urword_code
"2DROP",2drop
176 urword_code
"SWAP",swap
181 urword_code
"2SWAP",2swap
182 ;; ( n0 n1 n2 n3 -- n2 n3 n0 n1 )
186 xchg [esp],eax ; EAX=n0
193 urword_code
"OVER",over
199 urword_code
"2OVER",2over
200 ;; ( n0 n1 n2 n3 -- n0 n1 n2 n3 n0 n1 )
209 urword_code
"ROT",rot
218 urword_code
"NROT",nrot
227 urword_alias
"-ROT",nrot_alias
,nrot
230 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
232 urword_code
"NIP",nip
239 urword_code
"TUCK",tuck
240 ;; ( n1 n2 -- n2 n1 n2 )
248 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
249 urword_code
"DEPTH",depth
250 ;; ( -- stack-depth-before-this-call )
252 ld TOS
,[fvar_sp0_data
]
259 urword_code
"RDEPTH",rdepth
260 ;; ( -- rstack-depth-before-this-call )
262 ld TOS
,[fvar_rp0_data
]
269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
270 urword_code
"PICK",pick
271 ;; ( ... idx -- ... n[top-idx-1] )
272 ;; remove idx, copy item; 0 PICK is the same as DUP
277 urword_code
"ROLL",roll
278 ;; ( ... idx -- ... n[top-idx-1] )
279 ;; remove idx, move item; 0 ROLL is the same as NOOP
297 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
298 urword_code
"RPICK",rpick
299 ;; ( ... idx -- ... n[top-idx-1] )
300 ;; remove idx, copy item from return stack; 0 RPICK is the same as R@