[Á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:
=F6 INDEX($C$2:$C99999,$G2,1), IF(AND(INDEX($B$2:$B99999,$G2,1)="JZ",$I2=0), INDEX($C$2:$C99999,$G2,1), IF(AND(INDEX($B$2:$B99999,$G2,1)="JNZ",$I2<>0), INDEX($C$2:$C99999,$G2,1), G2+1 ) ) ) )
[Á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”
One day soon, Excel itself will be written in this way…..
Many people in engineering working on replacing SAP & SQL with Excel.
ASk 5 Times “Why”, and the third “why” will be “because there was an error in the Excel sheet”
As someone currently working on a SAP integration, I would happily give my left testicle to not have to see it ever again.
You sir, are so right.
I teach my peers that everytime you use excel, a puppy dies.
What do you use for a spreadsheet, or do you just keep all the math in your head?
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).
Might I propose a thought exercise.
Without answering never – When IS a spreadsheet the right tool for the job?
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.
For playing EVE online
Excel is like the Arduino of the business world.
I fail to see why that got the harvard architecture tag ;)
Because it can read an instruction AND data simultaneously?
Where the !@#$ is the “Like” button?! This phrase is ridiculously funny, I don’t know why.
This strikes me as a reasonable way of teaching assembly
You mean if you lack any sort of editor and an assembler which is never? It is never reasonable to suggest that excel has any benifitnat all, but this is blassm’phemy.
This is some masochist level shit right here.
A similar approach can be used to generate QR codes in Excel: http://blog.ambor.com/2013/03/create-qr-codes-in-excel-or-any.html
Do I see this right, to download this I need to be part of a “Social”-Network?
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.
And here I thought this was about a FSM coded through Excel.
my Free Excel 2010 do not use macros :(
Late on this, but I once found an implementation of a back-prop ANN for Excel…
Please be kind and respectful to help make the comments section excellent. (Comment Policy)