Assembly Language I/O Operations

Master character input and output with interactive examples

IN
Character Input Operations
CIF, SKI Check input flag
     BUN CIF Branch back to check again Flag=0: No input ready
     INP Input character to AC Flag=1: Character available
     OUT Print character (optional)
     STA CHR Store character in memory
     HLT Halt program
CHR, - Store character here
🔄 Input Process Flow
Check Flag (CIF)
→
Flag=0? Wait
→
Flag=1? Read (INP)
→
Store Character
💡 Complete Input Example
CIF,    SKI         // Check if input is ready
        BUN LOOP    // Branch back if no input
        INP         // Read character into AC
        STA CHR     // Store in memory location CHR
        HLT         // Stop program
CHR,    HEX 0000    // Memory location for character
AC
CHR
I/O
OUT
Character Output Operations
     LDA CHR Load character from memory to AC
COF, SKO Check output flag
     BUN COF Branch back to check again Flag=0: Output busy
     OUT Output character from AC Flag=1: Ready to output
     HLT Halt program
CHR, HEX 0057 'W' character
🔄 Output Process Flow
Load Character (LDA)
→
Check Flag (COF)
→
Flag=1? Output (OUT)
→
Character Displayed
💡 Complete Output Example
          LDA CHR     // Load character 'W' into AC
LOOP,    COF         // Check if output is ready
          SKO         // Skip if output flag = 1
          BUN LOOP     // Branch back if output busy
          OUT         // Send character to output
          HLT         // Stop program
CHR,     HEX 0057     // ASCII code for 'W' (87 decimal)
📊 ASCII Reference
'A'
41
'W'
57
'0'
30
'9'
39

ASCII values shown in hexadecimal

🎮 Interactive I/O Simulation

Experience how assembly I/O operations work!

Click a button to see the simulation...
?
Key Concepts Explained
🚩 What are Flags?

Input Flag: Indicates when a character is ready to be read from input device.

Output Flag: Indicates when the output device is ready to accept a new character.

Polling: The process of repeatedly checking flags until they indicate readiness.

âš¡ Why Use Skip Instructions?

SKI (Skip on Input): Efficiently checks if input is ready without complex branching.

SKO (Skip on Output): Efficiently checks if output is ready without complex branching.

Efficiency: Skip instructions make polling loops more compact and faster.

🔄 Program Flow

Polling Loop: Program waits in a loop until I/O device is ready.

Synchronization: Ensures data integrity between CPU and I/O devices.