Beispiel #1
0
 /** Check if Interrupt occurs, if yes, push PC to Stack & go to 0x4 */
 public void checkInterrupt() {
   if (interna.getInterrupt() && !isInterrupted) {
     //			isInterrupted = true;
     this.getInterna().getPcstack().push(this.getPC());
     this.setPC(0x4 - 1);
     interna.clearBitAt(0xb, 7);
   }
 }
Beispiel #2
0
 /**
  * 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();
 }
Beispiel #3
0
 /**
  * Bit of Port A is Clicked Checks TMR0 Source Select Bit & impulse edge
  *
  * @param column Bit of Port A
  */
 private void portAClicked(int column) {
   int bit = interna.getBitAtNoBank(0x5, 7 - column); // toggle bits
   if (bit == 0) interna.setBitAt(0x5, 7 - column);
   else interna.clearBitAt(0x5, 7 - column);
   boolean oldV = (bit != 0);
   boolean newV = (interna.getBitAtNoBank(0x5, 4) != 0);
   if (column == 3 && interna.getBitAt(0x81, 5) == 1) { // TMR0 Clock Source Select Bit
     if (interna.getBitAt(0x81, 4) == 1) { // inc high-to-low
       if (!newV && oldV) {
         interna.incTMR0();
       }
     } else { // inc low-to-high
       if (newV && !oldV) {
         interna.incTMR0();
       }
     }
   }
   updateGui();
 }
Beispiel #4
0
  /** 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;
    }
  }
Beispiel #5
0
 public void setPC(int a) {
   interna.setValueAt(a, 0x2);
 }
Beispiel #6
0
 public int getPC() {
   return interna.getValueAt(0x2);
 }
Beispiel #7
0
  /**
   * A Bit of Port B is Clicked Checks Interrupt Bits and impulse edge
   *
   * @param column Bit of Port B
   */
  private void portBClicked(int column) {
    int bit = interna.getBitAtNoBank(0x6, 7 - column); // toggle bits
    if (bit == 0) interna.setBitAt(0x6, 7 - column);
    else interna.clearBitAt(0x6, 7 - column);

    boolean oldB = (bit != 0);
    boolean newB = (interna.getBitAtNoBank(0x6, 4) != 0);
    if (interna.getBitAt(0xB, 7) == 1) { // GIE Enabled
      if (interna.getBitAt(0xB, 3) == 1 && column <= 3) { // rb port changed
        interna.setBitAt(0xB, 0);
      } else if (interna.getBitAt(0xB, 4) == 1 && column == 7) { // rb0 interrupt
        if (interna.getBitAt(0x81, 6) == 1) { // check interrupt-edge
          if (newB && !oldB) {
            interna.setBitAt(0xB, 1);
          }
        } else {
          if (!newB && oldB) {
            interna.setBitAt(0xB, 1);
          }
        }
      }
    }
    updateGui();
  }