public int run() {
		int curInstAddress = instructionAddress;
		while (cycles < Integer.MAX_VALUE) {
			cycles++;
			// Fetch new instruction
			if (!instructionBuffer.isFull()) {
				int instIndex = (instMemory.read((short) curInstAddress))
						.getData();
				if (!(instIndex < 0 || (curInstAddress-instructionAddress)/2 >= program.size())){		
					System.out.println((curInstAddress-instructionAddress)/2);
					
					instructionBuffer.insert(program.get((curInstAddress-instructionAddress)/2));
					curInstAddress += 2;
				}
			}
			// Issue new instruction
			if(!instructionBuffer.isEmpty()){
				Instruction myIn = instructionBuffer.getFirst();
				int type = myIn.getType();
				int index = stations.checkFree(type);
				if (index != -1) {
					int robIndex = rob.insert(new ReOrderObject(myIn, 0)); // REPLACE
																			// ZERO
																			// BY
																			// MEMORY
																			// ADDRESS
					stations.getStations()[type][index].loadInstruction(myIn,
							robIndex);
					instructionBuffer.removeFirst();
				}
			}
			// Execute in reservation stations
			LinkedList<ReservationStation> doneStations = stations.runCycle();
			for (ReservationStation rs : doneStations) {
				rs.writeBack();
				rs.reset();
			}
			// commit changes
			rob.commit();
			if (rob.isEmpty()){
				break;
			}
		}
		return cycles;
	}