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
Showing only changes of commit 22dc1fc0ca - Show all commits

8
asm.js
View File

@@ -112,6 +112,7 @@ const Action = Object.freeze({
DATA: 11, DATA: 11,
ALIGN: 12, ALIGN: 12,
DEF: 13, DEF: 13,
LABEL: 14,
}); });
const types = { const types = {
@@ -224,6 +225,8 @@ class Parser {
this.state = state; this.state = state;
return; return;
} }
if (token.endsWith(":"))
return { type: Action.LABEL, name: token.slice(0, -1) };
const code = this.translate_code(token); const code = this.translate_code(token);
if (code) if (code)
return { type: Action.APPEND, code }; return { type: Action.APPEND, code };
@@ -630,6 +633,7 @@ export class Assembler {
[Action.DATA]: (action) => this.action_data(action), [Action.DATA]: (action) => this.action_data(action),
[Action.ALIGN]: (action) => this.action_align(action), [Action.ALIGN]: (action) => this.action_align(action),
[Action.DEF]: (action) => this.action_def(action), [Action.DEF]: (action) => this.action_def(action),
[Action.LABEL]: (action) => this.action_label(action),
}; };
this.exports = []; this.exports = [];
@@ -741,6 +745,10 @@ export class Assembler {
this.defs[action.def.name] = action.def.value; this.defs[action.def.name] = action.def.value;
} }
action_label(action) {
this.defs[action.name] = this.pos.addr;
}
push(chunk) { push(chunk) {
const text = this.decoder.decode(chunk, { stream: true }); const text = this.decoder.decode(chunk, { stream: true });
for (const action of this.parser.handle(text)) for (const action of this.parser.handle(text))