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 b85a4e8bc9 - Show all commits

30
asm.js
View File

@@ -578,7 +578,7 @@ class Parser {
} else { } else {
if (value > 0xff) if (value > 0xff)
console.error(`WARNING: Value ${token} is truncated`); console.error(`WARNING: Value ${token} is truncated`);
action.value = [ value & 0xff ]; action.value = value;
} }
return action; return action;
} }
@@ -595,12 +595,7 @@ class Parser {
} else { } else {
if (value > 0xffffffff) if (value > 0xffffffff)
console.error(`WARNING: Value ${token} is truncated`); console.error(`WARNING: Value ${token} is truncated`);
action.value = [ action.value = value;
value & 0xff,
(value >> 8) & 0xff,
(value >> 16) & 0xff,
(value >> 24) & 0xff,
];
} }
return action; return action;
} }
@@ -614,8 +609,8 @@ class Parser {
`ERROR: Unexpected token ${token}, expected string`); `ERROR: Unexpected token ${token}, expected string`);
return; return;
} }
const value = this.encoder.encode(token.string); const bytes = this.encoder.encode(token.string);
const action = { type: Action.DATA, size: value.length, value }; const action = { type: Action.DATA, size: bytes.length, bytes };
return action; return action;
} }
@@ -1010,17 +1005,26 @@ export class Assembler {
action_data(action) { action_data(action) {
const data = this.data.at(-1).data; const data = this.data.at(-1).data;
let bytes;
if (action.bytes != undefined) {
bytes = action.bytes;
} else {
let value = action.value; let value = action.value;
if (value == undefined) { if (value == undefined) {
const raw = this.lookup_def(action.symbol); if (action.symbol == undefined) {
if (raw == undefined) { console.error("ERROR: Invalid data action", action);
return;
}
value = this.lookup_def(action.symbol);
if (value == undefined) {
console.error( console.error(
`ERROR: Unable to resolve symbol ${action.symbol}`); `ERROR: Unable to resolve symbol ${action.symbol}`);
return; return;
} }
value = this.le(raw, action.size);
} }
data.push(...value); bytes = this.le(value, action.size);
}
data.push(...bytes);
this.pos.addr += action.size; this.pos.addr += action.size;
} }