1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; UrForth level
1: self
-hosting
32-bit Forth compiler
3 ;; Copyright
(C
) 2020 Ketmar Dark
// Invisible Vector
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 format ELF executable
3
8 $entry urforth_entry_point
10 ;; this is defined by the target compiler
11 ;;urforth_code_base_addr equ $
13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 URFORTH_DEBUG equ URFORTH_DEBUGGER_ENABLED
15 URFORTH_EXTRA_STACK_CHECKS equ
0
17 ;; various compile
-time options
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29 ;; esi
: instruction pointer
32 ;; direction flag must NOT be set
!
35 ;; let it always be here
37 ;; universal dispatcher
for "next" command
38 ;; debugger will patch jump
to itself here
39 ;; when debugger is not active
, this will be simple
"jmp eax"
40 ;; startup code will patch it
to "jmp eax"
41 ;; reserve
32 bytes
for this
, because why not?
48 $label urforth_next_ptr
49 dd urforth_next_normal
51 $label urforth_next_normal
56 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
58 $
if WLIST_HASH_BITS
< 0
59 $error
"invalid WLIST_HASH_BITS: should be [0..8]!"
62 $
if WLIST_HASH_BITS
> 8
63 $error
"invalid WLIST_HASH_BITS: should be [0..8]"
66 ;; sorry
! one day i
'll implement shifts in asm evaluator
67 $if WLIST_HASH_BITS = 1
68 WLIST_HASH_MASK equ 0x01
69 WLIST_HASH_CELLS equ 2
72 $if WLIST_HASH_BITS = 2
73 WLIST_HASH_MASK equ 0x03
74 WLIST_HASH_CELLS equ 4
77 $if WLIST_HASH_BITS = 3
78 WLIST_HASH_MASK equ 0x07
79 WLIST_HASH_CELLS equ 8
82 $if WLIST_HASH_BITS = 4
83 WLIST_HASH_MASK equ 0x0f
84 WLIST_HASH_CELLS equ 16
87 $if WLIST_HASH_BITS = 5
88 WLIST_HASH_MASK equ 0x1f
89 WLIST_HASH_CELLS equ 32
92 $if WLIST_HASH_BITS = 6
93 WLIST_HASH_MASK equ 0x3f
94 WLIST_HASH_CELLS equ 64
97 $if WLIST_HASH_BITS = 7
98 WLIST_HASH_MASK equ 0x7f
99 WLIST_HASH_CELLS equ 128
102 $if WLIST_HASH_BITS = 8
103 WLIST_HASH_MASK equ 0xff
104 WLIST_HASH_CELLS equ 256
107 WLIST_HASH_BYTES equ WLIST_HASH_CELLS*4
110 ;; create "FORTH" vocabulary header first, because why not
111 $vocabheader "FORTH" forth_wordlist_vocid
113 $include 00_startup.f
114 $include 01_segfault_handler.f
115 $include 02_debugger.f
116 $include 03_do_codeblocks.f
117 $include 05_base_vars.f
118 $include 07_syscall.f
119 $include 08_termio_low.f
120 $include 10_litbase.f
123 $include 16_peekpoke.f
125 $include 18_simple_malloc.f
126 $include 19_dbg_info.f
127 $include 20_math_base.f
128 $include 21_math_compare.f
129 $include 22_math_muldiv.f
130 $include 24_math_double.f
131 $include 28_print_number.f
132 $include 30_count_str.f
133 $include 31_ur_str_ext.f
134 $include 32_str_hash_name.f
135 $include 34_str_hash_more.f
136 $include 36_str_ext_asm.f
137 $include 38_c4s_str.f
138 $include 39_c1s_str.f
139 $include 40_termio_high.f
141 $include 46_os_face.f
143 $include 52_exceptions.f
144 $include 60_wordmisc.f
145 $include 61_wordfind_low.f
146 $include 62_create_vocbase.f
147 $include 63_wordfind_high.f
148 $include 64_voc_order.f
149 $include 66_voc_other.f
151 $include 70_compiler_helpers.f
152 $include 71_compiler_if_begin_do.f
153 $include 72_compiler_mid.f
154 $include 74_compiler_high.f
155 $include 76_compiler_override_enum.f
156 $include 78_compiler_sc_colon.f
158 $include 84_interpret.f
160 $include 88_main_startup.f
161 $include 89_cond_comp.f
164 $include 94_envquery.f
166 $include 98_ans_crap.f
168 $include 99_misc_tests.f
172 ;; WARNING! it cannot be "equ"!
173 $label urforth_code_end