public void write_disk(int device)
	{
		ProcessControlBlock pcb = process_table[device_q[device].getFirst().getProcessNumber()];
		int index = pcb.getAcc()+1;
		machine.devices[device].controlRegister.register[0] = DeviceControllerOperations.WRITE;
		try {
			machine.memory.setBase(pcb.getBase());
			machine.memory.setLimit(pcb.getLimit());
			machine.devices[device].controlRegister.register[1] = machine.memory.load(index);
			if(device == Machine.DISK)
			{
				machine.devices[device].controlRegister.register[2] = machine.memory.load(index+1);
				int start = machine.memory.load(index+3);
				machine.devices[device].controlRegister.register[3] = machine.memory.load(index+2);
				for(int i = 0; i < machine.memory.load(index+2); i++)
				{
					machine.devices[device].buffer[i] = machine.memory.load(start);
					start++;
				}
			} else if(device == Machine.DISKTWO) {
				machine.devices[device].controlRegister.register[2] = ((machine.memory.load(index+1) + machine.memory.load(index+2)) - device_q[device].getFirst().getDiskLength());
				int start = ((machine.memory.load(index+3) + machine.memory.load(index+2)) - device_q[device].getFirst().getDiskLength());
				int buf;
				if(machine.devices[device].buffer.length < device_q[device].getFirst().getDiskLength())
				{
					machine.devices[device].controlRegister.register[3] = machine.devices[device].buffer.length;
					buf = machine.devices[device].buffer.length;
				}else{
					machine.devices[device].controlRegister.register[3] = device_q[device].getFirst().getDiskLength();
					buf = device_q[device].getFirst().getDiskLength();
				}
				
				for(int i = 0; i < buf; i++)
				{
					machine.devices[device].buffer[i] = machine.memory.load(start);
					start++;
				}
			}
			machine.devices[device].controlRegister.startOperation();

		} catch (MemoryFault e) {
			e.printStackTrace();
		}

	}