-
Notifications
You must be signed in to change notification settings - Fork 1
/
debugexamples.dasm16
226 lines (207 loc) · 4.51 KB
/
debugexamples.dasm16
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; EXAMPLE AND DEBUG CODE
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:foo DAT 0xFFFF
:db DAT 0
:foo2 DAT 0xFFFF
:pid DAT 0
:pid2 DAT 0
:init SET X, 1
SET A, 0x06
JSR status_color
:loop1 set Y, 0
SET A, count4
SET B, 1
JSR fork
SET [pid], A
SET Z, A
:loop2 SET A, [pid]
ADD [db], 1
SET B, 1
ADD Y, 1
ADD [db], 0x10
JSR yield
ADD [db], 0x10
JSR wait
IFN B,0
SET PC, loop2
ADD X, 1
ADD [db], 0x100
IFG 4, X
SET PC, loop1
SET [CC], 0
SET X, 0
SET Y, 0
SET A, count4
SET B, 2
JSR fork
SET X,1
SET [db], 0xC000
SET A, fact
SET B, 1
SET X, 6
JSR fork
SET [pid], A
SET A, fact_col
SET Z, A
SET B, 1
SET X, 8
JSR fork
SET [pid2], A
SET A, show_foobar
SET B, 0
JSR fork
SET A, show_random
SET B, 0
JSR fork
:loop3 SET A, [pid]
SET B, 1
ADD Y, 1
JSR yield
JSR wait
IFN B,0
SET PC, loop3
SET Y, 0
:loop4 JSR yield
SET A, [pid2]
SET B, 1
ADD Y, 1
JSR wait
IFN B,0
SET PC, loop4
SET A, read_test
SET B, 0
JSR fork
; the end is an endless loop
SET A, type_text
JSR println
SET I, 0
:crash SET A, I
JSR yield
JSR getch
IFN A, 4
SET PC, cr_2
JSR scroll_down
SET PC, crash
:cr_2
IFN A, 3
SET PC, cr_3
SET A, [_pc_vidbase]
SET B, A
ADD B, 23
SET C, 12
JSR memcpy_rev
SET PC, crash
:cr_3
IFN A, 0
JSR printchar
SET B, I
AND B, 0x0fff
SET A, 1
IFE B, 0
JSR status_blink
ADD I, 1
SET PC, crash
:type_text
DAT "Type something here",0
:read_test
set A, videobuf
jsr reserve_screen
SET I, 0
:rtloop
ADD I, 1
SET A, I
JSR yield
AND A, 0xFF
IFN A, 0
SET PC, rtloop
SET A, rlbuf
SET B, 15
JSR readline
SET A, 0x0A
JSR printchar
SET A, 0x20
JSR printchar
SET A, rlbuf
JSR println
SET PC, rtloop
:rlbuf DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
:videobuf ;RESERVE 320
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DAT 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
:show_foobar
SET A, 1
JSR set_interactive
:show_foobar1
SET A, lbl_foo
JSR status_string
SET A, lbl_foo
JSR println
SET B, 100
SUB B, 1
JSR yield
IFN B, 0
SUB PC, 5
SET A, lbl_bar
JSR status_string
SET A, lbl_bar
JSR println
SET B, 100
SUB B, 1
JSR yield
IFN B, 0
SUB PC, 5
SET PC, show_foobar1
:lbl_foo
DAT "foo "
:lbl_bar
DAT "bar ", 0x0
:show_random
JSR random
JSR status_i2hex
SET A, 300
:_sr
JSR yield
SUb A, 1
IFN A, 0
SET PC, _sr
SET PC, show_random
:count4 SET I, 0
:loopc SET A, I
JSR yield
ADD I, 1
ADD [CC], 1
SET J, [CC]
IFG I, 3
SET PC, POP
SET PC, loopc
:fact_col
SET A, 0x34
JSR status_color
:fact
SET A, X
JSR fact_rec
SET PC, POP
:fact_rec
JSR yield
IFE A, 1
SET PC, POP
SET PUSH, A
SUB A, 1
JSR fact_rec
MUL A, POP
JSR yield
SET PC, POP
:cc DAT 0