Throw an error if given a program that's too long

This commit is contained in:
n loewen 2023-08-02 15:06:36 +01:00
parent 7b3ec6b025
commit 9f04c4d314
1 changed files with 6 additions and 1 deletions

View File

@ -10,9 +10,14 @@ const CPU = {
Acc: 0, Acc: 0,
memory: null, memory: null,
loadMemory: (data) => { // data: Uint8Array loadMemory: (data) => { // data: Uint8Array
// TODO: check length of data if (data.length > 256) { throw new Error("Out of memory error (program too long)"); }
CPU.memory = data; CPU.memory = data;
}, },
currentInstruction: {
opcode: null,
argument: null,
mnemonic: null,
}
} }