Fix (Assembler): Pad machine code output to a full $FF bytes
This commit is contained in:
parent
5fba7daf32
commit
6e897b7f74
16
assembler.js
16
assembler.js
|
|
@ -38,8 +38,11 @@ const mnemonics2opcodes = {
|
||||||
function decodeInstructions(line) {
|
function decodeInstructions(line) {
|
||||||
let lines = line.split(/\n/); // returns an array of lines
|
let lines = line.split(/\n/); // returns an array of lines
|
||||||
|
|
||||||
let machineCode = new Array(INITIAL_IP_ADDRESS).fill(0);
|
//let machineCode = new Array(INITIAL_IP_ADDRESS).fill(0);
|
||||||
machineCode[POINTER_TO_START_OF_DISPLAY_MEM] = START_OF_DISPLAY_MEM;
|
let machineCode = new Array(256).fill(0);
|
||||||
|
dbgExec(2, () => logMemory(new Uint8Array(machineCode)));
|
||||||
|
machineCode[POINTER_TO_DISPLAY] = DISPLAY_ADDR;
|
||||||
|
machineCode[POINTER_TO_KEYPAD] = KEYPAD_ADDR;
|
||||||
|
|
||||||
let labels = {};
|
let labels = {};
|
||||||
let constants = {};
|
let constants = {};
|
||||||
|
|
@ -174,8 +177,9 @@ function decodeInstructions(line) {
|
||||||
// DECODE!
|
// DECODE!
|
||||||
const op = mnemonics2opcodes[opName][addressingMode];
|
const op = mnemonics2opcodes[opName][addressingMode];
|
||||||
|
|
||||||
machineCode.push(op);
|
machineCode[IP] = op;
|
||||||
machineCode.push(arg_num);
|
machineCode[IP+1] = arg_num;
|
||||||
|
|
||||||
dbg(3, `IP: $${num2hex(IP)}, new code: $${num2hex(op)} $${num2hex(arg_num)}`);
|
dbg(3, `IP: $${num2hex(IP)}, new code: $${num2hex(op)} $${num2hex(arg_num)}`);
|
||||||
IP += 2;
|
IP += 2;
|
||||||
dbgGroupEnd(1, 'Input line');
|
dbgGroupEnd(1, 'Input line');
|
||||||
|
|
@ -198,10 +202,6 @@ function decodeInstructions(line) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an END at the end
|
|
||||||
machineCode.push('0');
|
|
||||||
machineCode.push('0');
|
|
||||||
|
|
||||||
return new Uint8Array(machineCode);
|
return new Uint8Array(machineCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue