Skip to content

Commit a6a6349

Browse files
committed
use runtime in uxn
1 parent f6ce903 commit a6a6349

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

source/backends/uxn.d

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class BackendUXN : CompilerBackend {
148148
output ~= "|100\n";
149149
output ~= "@on-reset\n";
150150
output ~= " #ffff .vsp STZ2\n";
151-
output ~= " calmain\n";
151+
output ~= " init\n";
152152
output ~= " BRK\n";
153153
}
154154

@@ -161,6 +161,21 @@ class BackendUXN : CompilerBackend {
161161
}
162162
}
163163

164+
if ("__uxn_program_exit" in words) {
165+
CallFunction("__uxn_program_exit");
166+
}
167+
else {
168+
WarnNoInfo("No exit function available, expect bugs");
169+
}
170+
171+
// create init function
172+
output ~= "@init\n";
173+
if ("__uxn_program_init" in words) {
174+
CallFunction("__uxn_program_init");
175+
}
176+
else {
177+
WarnNoInfo("No program init function available");
178+
}
164179
output ~= "JMP2r\n";
165180

166181
foreach (var ; globals) {
@@ -199,6 +214,8 @@ class BackendUXN : CompilerBackend {
199214
output ~= "&dstBank 0000\n";
200215
output ~= "&dstAddr 0000\n";
201216

217+
output ~= "@program_end\n";
218+
202219
// pad for the stack
203220
output ~= "|e0000\n";
204221
}

0 commit comments

Comments
 (0)