@Override
	public void run()
	{
		try
		{
			instructionCount = 0;
			while (true)
			{
				if (!runProg)
				{
					Thread.sleep(100);
					continue;
				}

				pollForInterrupts();
				
				fetch();
				decode();
				//System.out.println(Opcode.toString(pc - 2, opcode, operand) + "   ->   " + pc + ", " + acc + ", " + x);

				instructionCount++;
				if (instructionCount == INSTRUCTIONS_PER_INTERRUPT)
				{
					instructionCount = 0;
					trap(Trap.TIMER);
				}
			}
		}
		catch (DecodingFault ex)
		{
			ex.printStackTrace(System.err);
			trap(Trap.DECODE_FAULT);
		}
		catch (MemoryFault ex)
		{
			trap(Trap.MEMORY_FAULT);
		}
		catch (Throwable ex)
		{
			ex.printStackTrace(System.err);
			trap(Trap.CPU_FAULT);
		}
	}