The classic puzzle: move a stack of disks from one tower to another, one at a time, never putting a larger disk on a smaller one. Up to 15 disks can be used, and the computer tells you how many moves the task should take. More detailed instructions are given in the program, and a game in progress can be saved to tape and loaded again later.
Towers of Hanoi was written by Kristian Boisvert and published on the November 1986 issue of the Byte Power tape magazine, where it is listed as a strategy game with a one-minute loading time.
Program Analysis
The 8,896-byte BASIC program auto-runs at line 1. The game itself is machine code stored in the REM of line 0 (the REM also holds the disk and character graphics) and is entered with RANDOMIZE USR 27483. The BASIC that remains handles the tape side of saving a game.
Machine Code to BASIC Dispatch
Line 3 is GO TO (PEEK 65535): when the machine code needs BASIC it leaves a line number in address 65535 and returns. Line 10 saves the game state, line 20 loads it and line 100 quits with PRINT USR 0. The save writes 270 bytes from 34823 with SAVE A$ CODE 34823,270, asks you to rewind and verifies it; the load reads the same block back. After either, RANDOMIZE USR 27998 re-enters the game. The subroutine at line 110 asks for a file name and rejects names longer than 10 characters.
Notable Techniques
- Machine code in a line-0 REM, with BASIC used only for tape input and output.
- A one-byte line-number mailbox at 65535 lets the machine code choose which BASIC routine runs next.
- Like the other Byte Power programs, it checks the system variable at 23681 on start-up: the magazine told readers to
POKE 23681,0before loading so that the program would stop and list line 9999, which saves a personal backup copy.
Potential Issues
- Line 12 loops back to the name prompt on an empty name, but the load at line 21 has no such check; an empty name loads the next CODE file found on the tape.
- Because the dispatch reads only one byte, BASIC targets above line 255 cannot be reached this way; all targets used (10, 20, 100) are within range.
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

