-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforth.asm
More file actions
98 lines (74 loc) · 1.63 KB
/
forth.asm
File metadata and controls
98 lines (74 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
%include 'io_lib.inc'
%include 'macro.inc'
%include 'util.inc'
%include 'dict.inc'
global _start
section .data
last_word: dq link
dp: dq user_mem
in_fd: dq 0
section .text
_start:
xor eax, eax
push rax ; stdin
jmp init_impl
run:
dq docol_impl
main_loop:
dq xt_buffer
dq xt_read ; read the word
branchif0 exit ; word read error or empty string
dq xt_buffer
dq xt_find ; addr or 0
; dq xt_printnl
dq xt_pushmode
branchif0 .interpreter_mode
.compiler_mode:
;dq xt_comp_m
dq xt_dup ; copy address
branchif0 .compiler_number
dq xt_cfa ; xt_address
; Check command's flag. Immediate commands must be interpreted.
dq xt_isimmediate
branchif0 .notImmediate
.immediate:
dq xt_initcmd
branch main_loop
.notImmediate:
dq xt_isbranch
dq xt_comma
branch main_loop
.compiler_number:
dq xt_drop
dq xt_buffer
dq xt_parsei
branchif0 .warning
dq xt_wasbranch
branchif0 .lit
dq xt_unsetbranch
dq xt_savenum
branch main_loop
.lit:
dq xt_lit, xt_lit
dq xt_comma
dq xt_comma
branch main_loop
.interpreter_mode:
;dq xt_inte_m
dq xt_dup
branchif0 .interpreter_number
dq xt_cfa ; rax - execution address
dq xt_initcmd
branch main_loop
.interpreter_number:
dq xt_drop
dq xt_buffer
dq xt_parsei
branchif0 .warning
branch main_loop
.warning:
dq xt_drop
dq xt_warn
branch main_loop
exit:
dq xt_bye