20 lines
495 B
JavaScript
20 lines
495 B
JavaScript
import { Assembler } from './asm.js';
|
|
|
|
const assemble = (async () => {
|
|
const asm = new Assembler();
|
|
const resp = await fetch('wipforth.ws');
|
|
for await (const chunk of resp.body) {
|
|
asm.push(chunk);
|
|
}
|
|
return asm.wasm();
|
|
})();
|
|
|
|
self.onmessage = async (e) => {
|
|
const exports = { emu: { mem: e.data } };
|
|
const wasm = await assemble;
|
|
const mod = await WebAssembly.instantiate(wasm, exports);
|
|
await self.postMessage('booting');
|
|
mod.instance.exports.reset();
|
|
console.log('System halt');
|
|
};
|