Skip to content

Input-Output Instructions

🔌 Input-Output Instructions


Definition

Input-Output Instructions are used to transfer data between the CPU and external devices (like keyboard, printer, monitor, etc.). They control how the CPU interacts with I/O devices through the I/O interface.


🧩 Instruction Format (16-bit)

In basic computer architecture:

| 15-13 | 12 - 1         | 0 |
| 111 | I/O Control Bits | 1 |
  • Opcode (15-13) = 111 (indicates Register or I/O instruction)
  • Bit 0 (I-bit) = 1 ➝ indicates I/O instruction
  • Bits 1-12: I/O Control bits (only one bit is set at a time)

🔁 I/O Concept (Simplified)

The CPU does not access I/O devices directly. Instead, data is transferred through I/O registers:

  • INPR (Input Register) – holds data from input device
  • OUTR (Output Register) – holds data to be sent to output device
  • FGI (Input Flag) – indicates if input is ready
  • FGO (Output Flag) – indicates if output is ready

🛠️ Key Input-Output Instructions

MnemonicOperationDescription
INPAC ← INPRRead a character from input device
OUTOUTR ← ACOutput a character to output device
SKISkip if FGI = 1Skip next instruction if input ready
SKOSkip if FGO = 1Skip next instruction if output ready
IONInterrupt enable ← 1Enable the interrupt system
IOFInterrupt enable ← 0Disable the interrupt system

🔍 Explanation of Each Instruction

1. INP (Input)

  • Action: Transfers data from INPR to AC
  • Use: Reading input character (like a key press)

2. OUT (Output)

  • Action: Transfers data from AC to OUTR
  • Use: Sending character to output device (like screen)

3. SKI (Skip on Input flag)

  • Action: If FGI = 1 (input ready), skip next instruction
  • Use: Polling to check if input is available

4. SKO (Skip on Output flag)

  • Action: If FGO = 1 (output ready), skip next instruction
  • Use: Polling to check if output device is free

5. ION (Interrupt ON)

  • Action: Enables CPU to accept interrupt requests
  • Use: Important for interrupt-driven I/O systems

6. IOF (Interrupt OFF)

  • Action: Disables interrupts
  • Use: Used when CPU must not be disturbed

📘 Working Mechanism

  1. Input device sends data to INPR
  2. When data is ready, FGI is set to 1
  3. CPU checks FGI using SKI, reads using INP
  4. For output, CPU writes to OUTR using OUT
  5. When ready, FGO is set to 1, CPU checks using SKO

📊 I/O Techniques

MethodDescription
Programmed I/OCPU actively checks flags and reads/writes
Interrupt-driven I/OCPU continues processing; interrupted only when needed
DMA (Direct Memory Access)Device transfers data directly to memory (CPU-free)

🧠 Why Important in CSA?

  • Teaches how CPU communicates with external devices
  • Builds the base for interrupts, flags, and device polling
  • Explains the control unit’s role in I/O operations

Conclusion

Input-Output Instructions are essential for:

  • Enabling interaction between CPU and external devices
  • Managing data flow between system and peripherals
  • Implementing polling, interrupts, and I/O control

These instructions form the bridge between software and hardware for all external operations.