public void run() {
        if (compiled == false) {
            Console.log("Please compile before running this program.", "error");
            return;
        }
        cancelled = false;
        short currentInst = 0x0800;
        //int counter = 0;
        try {
            if (!running) {
                PC = 0;
                SP = MemoryIO.SP_ADDR;
                running = true;
                Console.clear();
                Console.log("Running program...", "info");
                memory.init(PC);
            }
            while (!cancelled) {
                //System.out.println(PC);
                currentInst = memory.get(PC);
                if (currentInst == 0) {
                    break;
                }
                PC++;
                //counter++;
                if (PC < 0 || PC > Short.MAX_VALUE) {
                    throw new CounterOverflowError(PC);
                }
                execute(currentInst);
                if (uiConfig.breakpoints.contains((int) PC)) {
                    Console.log("Program paused on breakpoint at " + PC, "emphasis");
                    updateUI();
                    return;
                }
            }
        //memory.stop(PC);
        } catch (RuntimeError error) {
            Console.log("Runtime Error in instrucion:\t" + Misc.decode(currentInst), "error");
            Console.log(error.getMessage(), "error");
        }
        memory.stop(PC);
        Console.log("Program exits.", "emphasis");
        running = false;
        updateUI();
    }