private void sysCallWrite()
    {
        int data = m_CPU.popStack();
        int addr = m_CPU.popStack();
        int deviceID = m_CPU.popStack();
        //SOS.debugPrintln("sysCallWrite");
        //If the device exists
        DeviceInfo di;
        if((di = findDevice(deviceID)) != null)
        {
            //If the device is actually open
            if(di.procs.contains(m_currProcess))
            {
                //And if the device is writeable
                if(di.device.isWriteable())
                {
                    //And if the device is available
                    if(di.device.isAvailable())
                    {
                        di.device.write(addr, data);
                        try { Thread.sleep(15); }
                        catch (InterruptedException e) { e.printStackTrace(); }
                        
                        //Block the process and wait for the operation to be successful
                        m_currProcess.block(m_CPU, di.device, SYSCALL_WRITE, addr);
                    }
                    //Otherwise move the process to Ready and let it wait for the device
                    else
                    {
                        //Decrement the PC counter to make sure the TRAP will be executed again
                        m_CPU.setPC(m_CPU.getPC() - CPU.INSTRSIZE);
                        //Push the address and device ID back to the stack
                        m_CPU.pushStack(deviceID);
                        m_CPU.pushStack(addr);
                        m_CPU.pushStack(data);
                        m_CPU.pushStack(SYSCALL_WRITE);
                    }
                    scheduleNewProcess();
                }
                else
                    m_CPU.pushStack(ERROR_DEVICE_READ_ONLY);
            }
            else
                m_CPU.pushStack(ERROR_DEVICE_CLOSED);
        }
        else
            m_CPU.pushStack(ERROR_DEVICE_NOT_FOUND);
    }