Amiga MFM possibilities

Today, while thinking how the heck I’m going to integrate my 3mbps Parallax USB to Serial converter, I was trying to figure out exactly how many different possibilities there are coming out of an Amiga floppy drive. Since there are strict limitations on the number of one’s in a row (one!), and the number of zero’s(three) then this seriously limits the character set of the output. So the output is no longer 256 different choices. I long knew that, and doing character distribution tests on my output files, even though they were partially corrupt, I could see that this set was very small. I wanted to find out exactly how small.

There are only 32 possible MFM bytes! Too many zeros, or too many one’s ruled out all the others.

Note that you could go further and create valid groupings like cryptographers do with knowing that only certain letters follow only certain other letters, and NEVER follow a different letter, etc.

In HEX, the following bytes are the only possible MFM output from an amiga floppy disk:

0x11, 0x12, 0x14, 0x15
0x22, 0x24, 0x25, 0x28, 0x29, 0x2A
0x44, 0x45, 0x48, 0x49, 0x4A
0x51, 0x52, 0x54, 0x55
0x88, 0x89, 0x8A
0x91, 0x92, 0x94, 0x95
0xA2, 0xA4, 0xA5, 0xA8, 0xA9, 0xAA

I’m not sure exactly how this helps my cause but this means only 5-bits really *need* to get communicated back to the PC to represent all the possibilities, not 8-bits. This may save transfer time or something.

About the author


Amateur Electronics Design Engineer and Hacker


  • Earlier you mentioned
    “It seems that the PC really likes EVEN delays between data”.

    Perhaps you could attempt to stream bytes out extremely evenly,
    like a regular heartbeat.

    Pick a “heartbeat” slightly faster than bytes come in from the floppy.

    If you’re done transmitting a byte, and the next heartbeat comes before the next byte from the floppy is ready, send out “keep-alive” dummy bytes, until a real data byte comes in from the floppy.

    Naturally, you’d pick a “keep-alive” byte *other* than one of the bytes listed above.
    The software on the PC would throw away any “keep-alive” bytes it recieved.

  • Hi!

    I’m doing similar work with floppy drives (but not amiga related) and I could really appreciate any info you might have.
    I’ve read your blog (all of it and might do it again :D) and I wonder if you can point me to some documentation that define the MFM encoding used (for instance, how is the first bit encoded?)

    Any help would be appreciated. thanks

  • I think Amiga MFM might be different from standard MFM. This is one area where I’d like to look at PC disks and see the similarities and differences.

    The amiga has a SYNC word that is in RAW MFM that starts out every sector.

    You’ll see plenty of mention of it here, 0xAAAAAAAA44894489.

    This sync word allows the receiver to tell when to start decoding. It basically helps with the framing.

    Then, after the SYNC word, clock bits are interleaved with data bits.

    The form goes “clock bit” “data bit” “clock bit” “data bit>” and so on.

    The first clock bit HAS to be a ‘0’ because the last RAW MFM bit is a ‘1’ (which is the last 9 in 44894489. 9 = 1001 binary)

    You can’t have back-to-back ones. You can’t have too many zeros in a row (amiga limit is 3 zeros in a row max.) — this helps maintain clock synchronization.

    Anytime your data bit is a ‘1’, the clock bits on either side must be a ‘0’.

    Let me try to dig up some links to documentation. I think I’ve posted them someplace in the blog, but it’s been awhile.

  • Well, PC format is quite more complex:

    After the index pulse ends, there is 12 zero bytes (clock pulses only) to synchronize the PLL. Then, comes the INDEX MARK. A sync word with some clocks missing just like Amiga’s 4489. The sync word repeats 3 times. Index mark in never checked.

    Then comes a little gap.

    —repeats for EACH sector—
    Then 12 zero bytes again, followed by another sync word called SECTOR MARK, 3 times. Then comes the track number, sector number, head number and X. All are binary bytes, The X is the sector length(0=128,1=256,2=512..up to 4096). Then 2 bytes of CRC16, Low first.
    Another small gap.
    Then 12 zero bytes again, followed by another sync word called DATA MARK, 3 times. Then the sector data itself followed by 2 bytes of CRC16, Low first.
    Sector ends with bigger gap.
    —end of repeat—

    MFM coding itself is the same as Amiga – one clock between two zero databits.
    But because PC writes each sector separately, gaps after the headers and after the data are needed. This is because the spin motor variations…

    I cant remember the sync words, but it is well described in the datasheet of Western Digital WD2797 controller. There is byte by byte description of the whole track here.