public void execute() {
		while(running){
			try{
				int idx = getProgramCounter();
				String opcode = "0x" + Integer.toHexString(code.getOpcode(idx)).toUpperCase();
				boolean imm = code.getImmediate(idx);
				boolean ind = code.getIndirect(idx);
				int arg = code.getArg(idx);
				INSTRUCTION_MAP.get(opcode).execute(arg, imm, ind);
			}catch(ArrayIndexOutOfBoundsException e){
				JOptionPane.showMessageDialog(
						frame, 
						"There was an error in accessing data memory.",
								"Warning",
								JOptionPane.OK_OPTION);
				halt();
			}catch(IndexOutOfBoundsException e){
				JOptionPane.showMessageDialog(
						frame, 
						"There was an error in accessing code of the program.",
								"Warning",
								JOptionPane.OK_OPTION);
				halt();
			}catch(NullPointerException e){
				JOptionPane.showMessageDialog(
						frame, 
						"There was a a Null Pointer, indicating that there is an error in the simulator.",
								"Warning",
								JOptionPane.OK_OPTION);
				halt();
			}catch(IllegalArgumentException e){
				JOptionPane.showMessageDialog(
						frame, 
					    "Illegal access to code\n"
					    	    + "Exception message: " + e.getMessage(),
					    	    "Run time error",
								JOptionPane.OK_OPTION);
				halt();
			}catch(DivideByZeroException e){
				JOptionPane.showMessageDialog(
						frame, 
						"Error: DIV by zero.\n"
								+ "Exception message: " + e.getMessage(),
								"Run time error",
								JOptionPane.OK_OPTION);
				halt();
			}
		}
		setChanged();
		notifyObservers();
	}