cpu - Add feature: Quit after cycle limit reached

This commit is contained in:
n loewen 2023-08-24 16:35:21 +01:00
parent 2802623c4c
commit 897749b108
1 changed files with 1 additions and 1 deletions

2
cpu.js
View File

@ -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);