A Compiler In Plain Text Also Plays Music

As a layperson reading about some branches of mathematics, it often seems like mathematicians are just people who really like to create and solve puzzles. And, knowing that computer science shares a lot of its fundamentals with mathematics, we can assume that most computer scientists are also puzzle-solvers as well. This latest project from [tom7] shows off his puzzle creating and solving skills with a readable file which is also a paper, which is also a compiler for C programs, which can also play music.

[tom7] started off with the instruction set for the Intel 8086 processor. Of the instructions available, he wanted to use only instructions which are also readable in a text file. This limits him dramatically in what this file will be able to execute, but also sets up the puzzle. He walks through each of the hurdles he found by only using instructions that also code to text, including limited memory space, no obvious way of exiting the program once it was complete, not being able to jump backward in the program (i.e. looping), and a flurry of other issues that come up once the instruction set is limited in this way.

The result is a sort of C compiler which might not be the most efficient way of executing programs, but it sure is the most effective way of showing off [tom7]’s PhD in computer science. As a bonus, the file can also play an antiquated type of sound file due to one of the available instructions being a call for the processor to interact with I/O. If you want to learn a little bit more about compilers, you can check out a primer we have for investigating some of their features.

Thanks to [Greg] for the tip!

18 thoughts on “A Compiler In Plain Text Also Plays Music

    1. If you receive this paper in a raw text file, it may be difficult to
      read because of its two-column layout. It should be typeset in a monospace font on pages 160 characters wide and 128 characters tall
      (this is 4x the typical density of a line printer from the 1980s or
      1990s). Many pages, including parts of this first one, have cropping
      marks outside the text body to make the correct alignment easier to
      verify.

  1. The part I like is that at the end of the file he lists the number of times of each character occurs in the file… including the listing of the number of times of each character! Very nice.

    1. That’s an old trick. “This sentence contains seven letter “e”s, fourteen “s”s, 4 “l”s and a “w”. Except accurate. There are sentences like that which are accurate, self-descriptive I think.

      1. Reminds me of a pair of the great “Metamagical Themas”, from Scientific American: On Self-Referential Sentences
        (January, 1981) and Self-Referential Sentences: A Follow-Up (January, 1982).
        https://archive.org/stream/MetamagicalThemas/Metamagical%20Themas,%20Hofstadter_djvu.txt

        There was even a reader’s letter, in a later number, describing the “single purpouse computer” he designed and built at home (100 % discreet logic, IIRC) to solve the puzzle the article posed to the readers.

        I’ll search a little more, to provide the links to the original articles.

        Enjoy,
        Best regards,
        A/P Daniel F. Larrosa

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.