4 ms·
In my implementation I simply set my run loop to break out if last_pc == cpu.pc. Thus an HLT instruction is virtually equivalent to an instruction setting the
by lloeki 15y ago
In my implementation I simply set my run loop to break out if last_pc == cpu.pc.
Thus an HLT instruction is virtually equivalent to an instruction setting the PC back to PC itself, which, unless an outside force sets PC or [PC] to something else (think shared memory between multiple CPUs), is an unbreakable infinite loop.
- dy9 15y agoSET PC, [SP++] SET PC, [--SP] SET PC, [location with I/O]
- lloeki 15y ago> SET PC, [SP++] > SET PC, [--SP] Good call, detecting (PC, SP) fixed point then, although using the stack to jump onto itself is wicked. I don't want to go and solve the halting problem either. > SET PC, [location with I/O] Qualifies as outside force. I'm not sure I want to write/run a program that JMP to an @ provided by I/O, this reads like an SQL injection.