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(); } }
public void MEM() throws IrregularStringOfBitsException, NotAlignException, MemoryElementNotFoundException, AddressErrorException, IrregularWriteOperationException { super.MEM(); // unlock the fp register in order to avoid WAW hazards // restoring the address from the temporary register long address = TR[OFFSET_PLUS_BASE].getValue(); // For the trace file Dinero din = Dinero.getInstance(); din.Load(Converter.binToHex(Converter.positiveIntToBin(64, address)), 4); MemoryElement memEl = memory.getCellByAddress(address); // reading from the memory element and saving values on LMD register TR[LMD_REGISTER].writeWord(memEl.readWord((int) (address % 8))); if (enableForwarding) { doWB(); } }
/** * Returns the signed numeric decimal value stored in this register. * * @return signed numerical value stored in this register */ public long getValue() { try { return Converter.binToLong(this.getBinString(), false); } catch (IrregularStringOfBitsException e) { e.printStackTrace(); this.reset(false); // azzeriamo il registro return 0; } }
public void pack() throws IrregularStringOfBitsException { // conversion of instruction parameters of "params" list to the "repr" form (32 binary value) repr.setBits(OPCODE_VALUE, OPCODE_VALUE_INIT); repr.setBits(Converter.intToBin(RS_FIELD_LENGTH, params.get(RS_FIELD)), RS_FIELD_INIT); repr.setBits(Converter.intToBin(RT_FIELD_LENGTH, params.get(RT_FIELD)), RT_FIELD_INIT); }