Skip to content
Techniques & Technology

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.

commodore-64 kernali/orom-routines 1982–present

Overview

The KERNAL 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. The name "KERNAL" is widely believed to be a printed-manual typo of "kernel" that became canonical; the "Keyboard Entry Read, Network, And Link" expansion is a later backronym, not Commodore's official meaning.

Fast facts

  • Entry points: located at $FF81–$FFF3, accessible via JMP vectors stored in RAM for easy patching.
  • Devices: numbered channels handle keyboard (0), tape (1), RS-232 (2), screen (3), printers (4-5), plotters (6-7), and disk drives (8-15).
  • User port: not a numbered KERNAL device — it's hardware on CIA#2 ports.
  • Compatibility: the same KERNAL concept appears in the VIC-20, PET, C16, and C128 families.

Common KERNAL entry points

AddressNamePurpose
$FF81SCINITInitialise screen editor
$FF84IOINITInitialise I/O chips (CIA, VIC-II, SID)
$FF87RAMTASTest RAM and clear
$FF8ARESTORRestore default I/O vectors
$FFA5ACPTRRead byte from serial bus
$FFA8CIOUTSend byte to serial bus
$FFB7READSTRead status of serial bus
$FFBASETLFSSet logical file number, device, secondary address
$FFBDSETNAMSet filename
$FFC0OPENOpen a file
$FFC3CLOSEClose a file
$FFC6CHKINSet channel for input
$FFC9CHKOUTSet channel for output
$FFCCCLRCHNClear all channels
$FFCFCHRINRead character from current input
$FFD2CHROUTOutput character to current output
$FFD5LOADLoad file into memory
$FFD8SAVESave memory to file
$FFE1STOPTest for STOP key pressed
$FFE4GETINGet character from keyboard buffer (non-blocking)
$FFEDSCREENGet screen dimensions (40, 25 in A, X)
$FFF0PLOTSet or get cursor position

Core services

  • OPEN/CLOSE: OPEN and CLOSE manage 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.

See also