Writing A Virtual Machine In Excel

[Ádám] participates in a competition called KöMaL. It’s a 9-times-a-month journal for junior high and high school students featuring math and physics problems. [Paul Erdős], one of the most published mathematicians of all time, was a huge participant and by far the most notable student to crack open a copy of KöMaL in its hundred-year history. [Ádám] was trying his hand at a problem in Excel, but the official rules prohibit the use of Excel macros. In a daze, he came up with one of the most clever uses of Excel: building an assembly interpreter with the most popular spreadsheet program.

This is a virtual Harvard architecture machine without writable RAM; the stack is only lots and lots of IFs.  The instructions – mostly load, MOV, JNZ, INC, and CMP solves this problem, examining two inputs to see if they multiples of each other. If you’re wondering, an example cell from [Ádám]’s Excel sheet looks like this:


[Ádám] has provided his Excel solution to the problem, available on the hackaday.io. It’s in Hungarian which really shouldn’t matter since it’s basically Excel and a pseudo-x86 instruction set. but the column labels will require a bit of Google Translate.

26 thoughts on “Writing A Virtual Machine In Excel

      1. I live by the rule that generally you can solve most problems, at minimum, two ways. One is utilizing excel and the other is doing it the right way with the right tool.
        If you think you need excel, you are simply unaware of the right tools and methods, ergo not qualified to handle the subject and should therefor be shot (if continuing insisting to use excel).

          1. Ad hoc data manipulation and simple reporting. One off kinda stuff. At my office, anything that is simple enough that the business user can handle it without involving IT, otherwise it has to go though the code release process (public company, SOX control type stuff).
            The main problem is when it becomes part of the business process. Stuff outside of source control with tricky insecure DB password setups, that only that one guy knows how it worked.

  1. Ironically, Excel is written in a C dialect itself called “Hungarian” after its architect and former Microsoft employee, Charles Simonyi. Look it up for more of the back story.

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.