KERNAL I/O Routines
The Commodore 64’s built-in service desk
The C64’s KERNAL ROM exposes a patchable API for keyboard, screen, tape, disk, and serial I/O—perfect for BASIC and assembly alike.
Overview
The KERNAL (Keyboard Entry Read, Network, And Link) ROM provides 39 entry points for device handling and system services. Commodore designed it as a stable “API” so BASIC, machine-code programs, and third-party cartridges could rely on consistent routines.
Fast facts
- Entry points: located at
$FF81–$FFF3, accessible via JMP vectors stored in RAM for easy patching. - Devices: numbered channels handle keyboard (0), screen (3), tape (1), disk (8), RS-232 (2/3), and user ports.
- Compatibility: the same KERNAL concept appears in the VIC-20, PET, C16, and C128 families.
Core services
- OPEN/CLOSE:
OPENandCLOSEmanage logical file numbers and devices. - GET/CHRIN: read characters from keyboard, tape, or disk.
- CHROUT: output characters, including control codes for screen formatting.
- LOAD/SAVE: high-level routines to move data between memory and mass storage.
Why patch it?
Cartridges and fastloaders replace selected vectors to accelerate disk/tape access or add tooling. Understanding the KERNAL is essential for compatibility and for falling back gracefully when hardware mods are absent.