cpu - Fix: Make sure that the 'reached cycle limit' message displays in all output modes
This commit is contained in:
parent
9f68bd3027
commit
86d0b57c7a
12
cpu.js
12
cpu.js
|
|
@ -321,12 +321,6 @@ function startCPU(code) {
|
||||||
* @param {Boolean} [debug] - Print machine status and the line of code being executed
|
* @param {Boolean} [debug] - Print machine status and the line of code being executed
|
||||||
**/
|
**/
|
||||||
async function stepCPU(debugInfo, debug = false, prettyPrintDisplay = false) {
|
async function stepCPU(debugInfo, debug = false, prettyPrintDisplay = false) {
|
||||||
if (CYCLE_LIMIT) { // Temporary limit as a lazy way to halt infinite loops
|
|
||||||
if (CPU.cycleCounter > CYCLE_LIMIT) {
|
|
||||||
console.warn('HALTING - reached cycle limit');
|
|
||||||
CPU.running = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CPU.IP >= CPU.memory.length) {
|
if (CPU.IP >= CPU.memory.length) {
|
||||||
console.error('HALTING - IP greater than memory size');
|
console.error('HALTING - IP greater than memory size');
|
||||||
CPU.running = false;
|
CPU.running = false;
|
||||||
|
|
@ -347,6 +341,12 @@ async function stepCPU(debugInfo, debug = false, prettyPrintDisplay = false) {
|
||||||
CPU.cycleCounter += 1;
|
CPU.cycleCounter += 1;
|
||||||
}
|
}
|
||||||
logCPUState(debugInfo, debug, prettyPrintDisplay);
|
logCPUState(debugInfo, debug, prettyPrintDisplay);
|
||||||
|
if (CYCLE_LIMIT) { // Temporary limit as a lazy way to halt infinite loops
|
||||||
|
if (CPU.cycleCounter >= CYCLE_LIMIT) {
|
||||||
|
console.warn(' HALTING - reached cycle limit');
|
||||||
|
CPU.running = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!CPU.running) process.exit();
|
if (!CPU.running) process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue