Reading IBM PC and PCjr Cassette Waveforms



Note: This page, and most of this site are being served from an IBM PCjr as an experiment. If anything seems terribly wrong please contact me at mbbrutman at gmail.com. Want to see the current statistics for the PCjr? Click here:

The IBM PC 5150 and the IBM PCjr are unique among PC family in that they have a cassette port for saving data. Cassette ports were common on machines from the late 1970s and early 1980s because diskette drives and diskettes were very expensive. In reality nobody probably ever used the cassette port on an IBM PC - it is just too slow and unreliable. Anybody who was forced to use a cassette on any machine would immediately buy a diskette drive, no matter what the cost.

Recently I found a copy of IBM Advanced Diagnostics for the IBM PC 5150 on cassette. It was tucked away into a Hardware Maintenance and Service manual. I've had it for a while and I finally decided that it was time to make a backup copy of the tape.

To record data onto a cassette the computer must take the binary data and convert it to audible sound, which is what gets recorded on the tape. To read the data the opposite occurs - the audible sound is converted to ones and zeros. If you listen to the recording it sounds mostly like noise, which is what is should sound like to a human. But it really is very structured noise - you just have to know how to read it.

Here is an excerpt from the Technical Reference for the IBM PC 5150:

The WRITE-BLOCK routine 'turns-on' the cassette drive motor and 'writes' the leader (256 bytes of all 1's) to the tape, 'writes' a synchronization bit (0), and then 'writes' a synchronization byte (ASCII character hex 16). Next, the routine 'writes' the number of data bytes specified by CX. After each data block of 256 bytes, a 2-byte cyclic redundancy check (CRC) is 'written'. The data bytes are taken from the memory location 'pointed' at by DS:BX.

The WRITE-BLOCK routine 'disassembles' and 'writes' the byte a bit-at-a-time to the cassette. The method used is to 'set' Timer 2 to the period of the desired data bit. The timer is 'set' to a period of 1.0 millisecond for a 1 bit and 0.5 millisecond for a 0 bit.

So in theory that passage tells us what we are listening to. Zero bits last for half of a millisecond and one bits last for a full millisecond. If I remember high-school physics correctly, a sound where the cycle of the waveform last for 1 second is a 1Hz frequency sound. So a one bit is represented by something around a 1000Hz tone and a 0 bit is represented by something around a 2000Hz tone. These are both within the range of human hearing but the duration of each tone is too short for a human to make sense of.

Lets take a look at the waveform using Audacity, a free sound recorder for Windows:

Cassette data waveform, no zoom

We can readily spot where the quiet parts are and where the noisy parts are, but this isn't very useful. Let's zoom in a bit though:


Cassette waveform, high zoom

Now this is interesting. Remember that zero bits are defined to be 0.5 milliseconds in length. The highlighted area shows you a portion of the waveform which according to the time tape at the top is 0.5 milliseconds in length. That is probably a zero bit. If you look at the next portion of the waveform you will see that it lasts for a full millisecond - that is probably a one bit.

We just read data from a cassette tape!

The excerpt from the technical reference says that the WRITE-BLOCK routine starts by writing 256 bytes of 1 bits, then a 0 bit, and then a hex 0x16 which looks like '00010110' in binary. The 256 bytes of 1 bits is known as the leader, and math says that it should last about 2.05 seconds. Lets find a quiet spot on the recording, move 2 seconds in, and take a peek:


End of leader and sync bit

In the shaded region you can see the end of the leader. The excerpt says that will be followed by a zero bit, and then a hex 0x16 (0b00010110). If you look at the waveform above you can see the last four 1 bits of the leader, the sync bit (a zero), and then the bits that make up 0x16 just like the excerpt says. The next bits are the start of the length bytes which tell the machine how much data to expect.

Click here for an MP3 file of the entire recording. If you get it to run on an original IBM PC 5150 let me know what it does! (I have not constructed a cassette interface cable for my machine yet.)


Created March 23rd, 2008, last updated March 23rd, 2008
(C)opyright Michael B. Brutman, mbbrutman at gmail.com