Egghead.page Logo

How Sinclair ZX81 Handled LIST Command for Long Programs

The Sinclair ZX81 managed the LIST command for long programs through a combination of BASIC tokenization, sequential memory reading, and controlled screen scrolling. Due to severe memory constraints, the computer stored code in a compressed format that required real-time decoding during listing, which significantly impacted output speed. This article details the technical processes behind token expansion, the behavior of the display when filling the screen, and the user input methods available to pause or halt the listing process.

To conserve its limited 1KB of RAM, the ZX81 stored BASIC keywords as single-byte tokens rather than full text strings. When a user invoked the LIST command, the machine’s ROM routine had to traverse the program lines stored in memory and decode these tokens back into readable ASCII characters for the television display. This decompression process required CPU cycles for every keyword encountered, meaning that listing a long program was not instantaneous but rather a deliberate process dictated by the processor’s speed and the complexity of the code.

As the decoded text filled the 24-line television screen, the ZX81 employed a scrolling mechanism to reveal subsequent lines of code. Unlike modern systems that might buffer output, the ZX81 printed lines directly to the display buffer, causing the text to scroll upward once the bottom of the screen was reached. This scrolling could appear slow to the user, especially in programs with many complex commands, as the Z80A processor prioritized the generation of the video signal alongside the decoding task.

Users maintained control over the LIST output through specific keyboard inputs designed to manage the flow of information. Pressing the SPACE bar would temporarily pause the scrolling, allowing the programmer to read specific sections of code without losing their place. To terminate the listing entirely, the user could press the BREAK key, which interrupted the ROM routine and returned control to the command prompt. These manual controls were essential for navigating lengthy programs within the hardware limitations of the era.