# 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:

```=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.