🔌 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
Mnemonic | Operation | Description |
---|---|---|
INP | AC ← INPR | Read a character from input device |
OUT | OUTR ← AC | Output a character to output device |
SKI | Skip if FGI = 1 | Skip next instruction if input ready |
SKO | Skip if FGO = 1 | Skip next instruction if output ready |
ION | Interrupt enable ← 1 | Enable the interrupt system |
IOF | Interrupt enable ← 0 | Disable 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
- Input device sends data to INPR
- When data is ready, FGI is set to 1
- CPU checks FGI using SKI, reads using INP
- For output, CPU writes to OUTR using OUT
- When ready, FGO is set to 1, CPU checks using SKO
📊 I/O Techniques
Method | Description |
---|---|
Programmed I/O | CPU actively checks flags and reads/writes |
Interrupt-driven I/O | CPU 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.