From 897749b108636123e1cade2007c379e21c179ff1 Mon Sep 17 00:00:00 2001 From: n loewen Date: Thu, 24 Aug 2023 16:35:21 +0100 Subject: [PATCH] cpu - Add feature: Quit after cycle limit reached --- cpu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu.js b/cpu.js index 7c0da07..ee9e414 100644 --- a/cpu.js +++ b/cpu.js @@ -334,6 +334,7 @@ async function stepCPU(debugInfo, debug = false) { if (CPU.IP >= CPU.memory.length) { console.error('HALTING - IP greater than memory size'); CPU.running = false; + process.exit(); } else { CPU.currentInstruction.opcode = CPU.memory[CPU.IP]; CPU.currentInstruction.operand = CPU.memory[CPU.IP+1]; @@ -344,7 +345,6 @@ async function stepCPU(debugInfo, debug = false) { console.error(`Error: Invalid opcode`); console.error(` Executing $${num2hex(info.machine[0])} $${num2hex(info.machine[1])}`); console.error(` from line ${info.lineNumber}: ${info.source}`); - console.error(); process.exit(); } executeInstruction(CPU.currentInstruction.operand);