From 9f04c4d314e5d3c086f79f7e819c4f5dd0e97502 Mon Sep 17 00:00:00 2001 From: n loewen Date: Wed, 2 Aug 2023 15:06:36 +0100 Subject: [PATCH] Throw an error if given a program that's too long --- simulator.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/simulator.js b/simulator.js index bf80c9a..7b2c646 100644 --- a/simulator.js +++ b/simulator.js @@ -10,9 +10,14 @@ const CPU = { Acc: 0, memory: null, 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; }, + currentInstruction: { + opcode: null, + argument: null, + mnemonic: null, + } }