Throw an error if given a program that's too long
This commit is contained in:
parent
7b3ec6b025
commit
9f04c4d314
|
|
@ -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,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue