Assemble kernel on the client #1

Merged
cdo merged 72 commits from client-side-assembler into main 2026-03-18 15:21:33 +00:00
3 changed files with 16 additions and 8 deletions
Showing only changes of commit 67fc1d8d7b - Show all commits

15
boot.js
View File

@@ -10,10 +10,17 @@ const assemble = (async () => {
})(); })();
self.onmessage = async (e) => { self.onmessage = async (e) => {
const exports = { emu: { mem: e.data } }; switch (e.data.type) {
case "load":
const exports = { emu: { mem: e.data.mem } };
const wasm = await assemble; const wasm = await assemble;
const mod = await WebAssembly.instantiate(wasm, exports); self.mod = await WebAssembly.instantiate(wasm, exports);
await self.postMessage('booting'); await self.postMessage('ready');
mod.instance.exports.reset(); break;
case "boot":
self.mod.instance.exports.reset();
console.log('System halt'); console.log('System halt');
break;
}
}; };

3
emu.js
View File

@@ -54,10 +54,11 @@ class Emulator {
this.print("Assembling kernel "); this.print("Assembling kernel ");
const dots = setInterval(() => this.print("."), DOT_INTERVAL_MS); const dots = setInterval(() => this.print("."), DOT_INTERVAL_MS);
this.worker = new Worker('boot.js', { type: 'module' }); this.worker = new Worker('boot.js', { type: 'module' });
this.worker.postMessage(this.mem); this.worker.postMessage({ type: "load", mem: this.mem });
this.worker.onmessage = (e) => { this.worker.onmessage = (e) => {
clearInterval(dots); clearInterval(dots);
this.print(" done\n"); this.print(" done\n");
this.worker.postMessage({ type: "boot" });
}; };
fetch('prelude.f') fetch('prelude.f')

View File

@@ -250,7 +250,7 @@ CHAR . EMIT
0 CONSTANT VERSION-MAJOR 0 CONSTANT VERSION-MAJOR
2 CONSTANT VERSION-MINOR 2 CONSTANT VERSION-MINOR
0 CONSTANT VERSION-PATCH 1 CONSTANT VERSION-PATCH
: PRINT-VERSION : PRINT-VERSION
CHAR v EMIT VERSION-MAJOR . CHAR v EMIT VERSION-MAJOR .