Esempio n. 1
0
  public void EX()
      throws IrregularStringOfBitsException, IntegerOverflowException, TwosComplementSumException {
    // getting strings from temporary registers
    String rt = TR[RT_FIELD].getBinString();
    String rs = TR[RS_FIELD].getBinString();
    String shift = "", rd;
    // getting the low order 5 bits from rs register
    shift = rs.substring(59);
    // cutting the high part of register
    rt = rt.substring(32, 64);
    int shift_value = Converter.binToInt(shift, true);
    // composing new shifted value and performing sign extension
    StringBuffer buf = new StringBuffer();

    for (int i = 0; i < 32; i++) {
      buf.append(rt.charAt(0));
    }

    buf.append(rt.substring(shift_value));

    // filling the remaining bits with 0
    for (int i = 0; i < shift_value; i++) {
      buf.append('0');
    }

    String target = new String(buf);

    TR[RD_FIELD].setBits(target, 0);

    if (enableForwarding) {
      doWB();
    }
  }