Esempio n. 1
0
 void fix_memory_table(JTable memoryTable) {
   DefaultTableModel model = new DefaultTableModel(new Object[] {"Address", "Content"}, 0);
   memoryTable.setModel(model);
   for (int i = 0; i < aa.getMemory().size(); i++) {
     model.addRow(new Object[] {aa.parse8DigitHex(i), aa.getMemory().get(aa.parse8DigitHex(i))});
   }
 }
Esempio n. 2
0
 public Computer() {
   runable = true;
   enableintrrupt = true;
   currentLineOfInstructions = 0;
   aa = new AddressAllocator();
   modeBit = true; // means in kernel Mode at first
   this.memory = "";
   for (int i = 0; i < aa.getMemory().size(); i++) {
     this.memory +=
         (aa.parse8DigitHex(i) + " : " + aa.getMemory().get(aa.parse8DigitHex(i)) + "\n");
   }
   //        cp0 = new CP0();
 }
Esempio n. 3
0
  public void func20() {
    // this function change pc to selected program (program pid must saved in v0)
    modeBit = false;
    enableintrrupt = true;
    interruptBit = false;
    System.out.println("func20");
    HashMap<Integer, SegmentDefragmenter> programsHashmap = aa.getPrograms();
    int selected = getRegfile().getRegfile(2);
    defaultRegisters = getRegfile();
    if (programs != null) {
      for (PCB program : programs) {
        if (program.getPid() == selected) {
          program.setSchedulingState(PCB.EXECUTE_STATE);
          stage_id.regfile = program.getRegs();
          currentProgram = program;
        }
      }
    }

    SegmentDefragmenter sd = programsHashmap.get(selected);
    String startadd = sd.getCode_seg_start_address();
    System.out.println("++++++++++++++++++++++++++++++++++++");
    System.out.println("start address said : " + startadd);
    System.out.println("ra said: " + Integer.toHexString(stage_id.regfile.getRegfile(31) * 4));
    System.out.println("++++++++++++++++++++++++++++++++++++");

    stage_if.setPC(Integer.parseInt(startadd, 16) / 4);

    lineOfInstructions = Integer.parseInt(startadd, 16) + sd.getCode_seg().size();
    modeBit = false;
    HashMap<Integer, Instruction> cache = new HashMap<Integer, Instruction>();

    int physicalAddress = Hex2Decimal(startadd);
    baseAddress = physicalAddress;
    sd.setCode_seg_start_address(parse8DigitHex(physicalAddress));
    for (int i = 0; i < sd.getCode_seg().size(); i++) {
      cache.put(
          stage_if.getPC() + i,
          new Instruction(sd.getCode_seg().get(i), parse8DigitHex(physicalAddress)));
      physicalAddress++;
    }
    stage_if.setIns_cache(cache);
    if (Integer.parseInt(Integer.toString(currentProgram.getPC(), 8)) >= 400000) {
      stage_if.setPC(currentProgram.getPC() * 4 / 4);
    } else {
      stage_if.setPC(Integer.parseInt(startadd, 16) / 4);
    }
  }