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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20 ;; virtual stack size, in bytes
21 urcond_stack_size
= 256 ;; should be enough for everyone
25 dd urcond_stack_size
;; this is SP
31 macro urcond_check_balance
{
33 load csp dword from urforth_conctl:0
34 if csp <> urcond_stack_size
36 display "*** UNBALANCED CONDITIONALS IN WORD: "
37 display urforth_last_word_name
39 err "unbalanced conditionals"
45 load csp dword from urforth_conctl:0
46 if csp = urcond_stack_size
47 err "cond stack underflow"
50 store dword csp at urforth_conctl:0
55 load csp dword from urforth_conctl:0
56 if csp = urcond_stack_size
57 err "cond stack overflow"
59 load vv dword from urforth_conctl:csp
61 store dword csp at urforth_conctl:0
67 load csp dword from urforth_conctl:0
69 err "cond stack overflow"
72 store dword n at urforth_conctl:csp
73 store dword csp at urforth_conctl:0
79 load csp dword from urforth_conctl:0
80 if csp > urcond_stack_size-8
81 err "cond stack underflow (swap)"
83 load v0 dword from urforth_conctl:csp
85 load v1 dword from urforth_conctl:csp
86 store dword v0 at urforth_conctl:csp
88 store dword v1 at urforth_conctl:csp
94 load csp dword from urforth_conctl:0
95 if csp+4 = urcond_stack_size
96 err "cond stack underflow (swap)"
99 load v dword from urforth_conctl:csp
111 ;;load csp dword from urforth_conctl:0
112 ;;if csp+8 > urcond_stack_size
113 ;; err "cond stack underflow (poke)"
115 ;;load addr dword from urforth_conctl:csp
117 ;;load value dword from urforth_conctl:csp
119 ;;store dword csp at urforth_conctl:0
124 value = urcond_popval
126 store dword value at addr
136 macro urcond_add delta
{
138 load csp dword from urforth_conctl:0
139 if csp = urcond_stack_size
140 err "cond stack overflow"
142 load n dword from urforth_conctl:csp
144 store dword n at urforth_conctl:csp
147 macro urcond_compback
{
155 macro urcond_compfwd
{
161 macro urcond_pairs pval
{
163 ;load n dword from urfhi_csp
164 ;urfhi_csp = urfhi_csp+4
168 err "unbalanced UrForth conditionals!"
240 ;load v0 dword from urfhi_csp
241 ;urfhi_csp = urfhi_csp+4
242 ;load v1 dword from urfhi_csp
243 ;urfhi_csp = urfhi_csp+4
282 call fword_par_urforth_nocall_doforth
285 macro ur_cblock_end
{