From 79ad1678f432e71d496561e9cd6a7cf9c3cf0ede Mon Sep 17 00:00:00 2001 From: n loewen Date: Tue, 15 Aug 2023 16:05:31 +0100 Subject: [PATCH] Feature (simulator): Add 'simulation halting - reached cycle limit' notice --- simulator.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/simulator.js b/simulator.js index 819a378..a690702 100644 --- a/simulator.js +++ b/simulator.js @@ -288,7 +288,11 @@ exports.runProgram = async (code, debug = false) => { let step = 0; while (true) { step = step + 1; - if (CYCLE_LIMIT && (step > CYCLE_LIMIT)) { break; } // Temporary limit as a lazy way to halt infinite loops: + // Temporary limit as a lazy way to halt infinite loops: + if (CYCLE_LIMIT && (step > CYCLE_LIMIT)) { + console.log('SIMULATION HALTING - reached cycle limit'); + break; + } if (!CPU.running) break; if (CPU.IP >= CPU.memory.length) break; stepCPU();