-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.fs
More file actions
100 lines (82 loc) · 1.33 KB
/
run.fs
File metadata and controls
100 lines (82 loc) · 1.33 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
99
100
needs vm/vm.fs
needs compiler/compile.fs
needs utils/strings.fs
: wait-for-key
key drop
;
: any-key-continue
." Hit any key to continue"
wait-for-key
;
: command-compile
." Compile:" cr
cr ." Enter source file (default: test.dasm): "
input$
get-counted-string
0 over = if
2drop
s" test.dasm"
then
cr ." Enter output file (default: test.dbin): "
input$
get-counted-string
0 over = if
2drop
s" test.dbin"
then
cr
2swap compile-file
any-key-continue
page
;
: command-vm-dump
." VM State: " cr
dump-vm-state cr
any-key-continue page
;
: command-run
." Run:" cr
cr ." Enter file to run (default: test.dbin) "
input$
get-counted-string
0 over = if
2drop
s" test.dbin"
then
cr
vm-run-file
command-vm-dump
;
create commands
' command-compile ,
' command-run ,
' command-vm-dump ,
: menu
begin
." DCPU-16:" cr
." ---------------------------" cr
." 1) Compile" cr
." 2) Run" cr
." 3) Dump VM State" cr
." q) Quit" cr
." l) Leave menu" cr
." ---------------------------" cr
." > " key
page
[char] q over = if
drop
bye
then
[char] l over = if
drop
exit
then
[char] 1 -
dup 2 > if
." *** Invalid choice! ***" cr
else
cells commands + @ execute
then
again
;
menu