/** * reset Register, Stack, etc if newProg==true, old Code&Hashmaps deleted * * @param newProg boolean true if new Prog is loaded */ public void reset(boolean newProg) { if (newProg == true) { gui.getListModel().clear(); decoder.clearHashMaps(); } setPC(0); curInstruction = 0; interna.setRegW(0); interna.initRegister(); interna.initStack(); updateGui(); }
/** Updates the GUI-Elements */ public void updateGui() { gui.getTextPane("Wreg").setText(Integer.toHexString(interna.getRegW())); gui.getTextPane("FSRreg").setText(Integer.toHexString(interna.getValueAt(0x4))); gui.getTextPane("TMR0").setText(Integer.toHexString(interna.getValueAtNoBank(0x1))); gui.getTextPane("PCLreg").setText(Integer.toHexString(interna.getValueAt(0x2))); gui.getTextPane("RP0").setText(String.valueOf(interna.getBitAt(0x3, 5))); gui.getTextPane("TO").setText(String.valueOf(interna.getBitAt(0x3, 4))); gui.getTextPane("PD").setText(String.valueOf(interna.getBitAt(0x3, 3))); gui.getTextPane("Z").setText(String.valueOf(interna.getBitAt(0x3, 2))); gui.getTextPane("DC").setText(String.valueOf(interna.getBitAt(0x3, 1))); gui.getTextPane("C").setText(String.valueOf(interna.getBitAt(0x3, 0))); // PortA for (int i = 0; i < gui.getPortA().getColumnCount(); i++) { gui.getPortA().setValueAt(Integer.valueOf(interna.getBitAtNoBank(0x5, i)), 0, 7 - i); gui.getPortA().setValueAt(interna.getTris(0x85, i), 1, 7 - i); } // PortB for (int i = 0; i < gui.getPortB().getColumnCount(); i++) { gui.getPortB().setValueAt(Integer.valueOf(interna.getBitAtNoBank(0x6, i)), 0, 7 - i); gui.getPortB().setValueAt(interna.getTris(0x86, i), 1, 7 - i); } // INTCON for (int i = 0; i < gui.getIntcon().getColumnCount(); i++) { gui.getIntcon().setValueAt(Integer.valueOf(interna.getBitAt(0x0B, i)), 0, 7 - i); } // Register int rowReg = 0x0; for (int i = 0; i < gui.getRegister().getRowCount(); i++) { for (int j = 0; j <= 7; j++) { gui.getRegister() .setValueAt(Integer.toHexString(interna.getValueAtNoBank(rowReg + j)), i, j + 1); } rowReg += 0x8; } }
/** Enable Gui */ public void initGui() { gui.setVisible(true); this.updateGui(); }
/** Highlight the line in Source Code which is executed */ public void updateSelectedLine() { int index = decoder.getLineNrToAddress(getPC()); gui.getCodeList().setSelectedIndex(index); gui.getCodeList().ensureIndexIsVisible(gui.getCodeList().getSelectedIndex()); }