Suramya's Blog : Welcome to my crazy life…

December 26, 2014

Writing A Virtual Machine In Excel

Filed under: Computer Software,My Thoughts,Techie Stuff — Suramya @ 6:03 PM

Microsoft Excel should soon be classified as an Operating System. In the past we have seen a 3D shoot them up Doom Clone, a Flight Simulator and other games included in it as Easter eggs. Then we saw people using it to watch movies at work, and now here’s the latest entry that forces Excel way outside its comfort zone…

A programmer named Ádám was participating in a contest where he had to solve a problem in Excel but the official rules prohibited the use of Excel macros so he went and created an assembly interpreter for Excel and used it to solve the problem instead. Talk about overkill. The idea is quite interesting. However the thought process required to imagine this as a possibility and then actually going ahead and implementing this is mind boggling.

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
         )
      )
   )
)

You can check out Adam’s solution at Hackaday.io if you are interested. I think I am going to go find my excel for Dummies book now and get just a little bit more proficient in it.

Thanks to hackaday.com for the original article.

-Suramya

1 Comment »

  1. […] are plenty of folks out there who are pushing the limits of both hardware and software. For example this virtual machine in Excel was created by a highschool student. If folks weren’t out there pushing the limits then […]

    Pingback by Suramya's Blog » Kids these days…. — December 29, 2014 @ 11:19 PM

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress