Monday, September 8, 2008

Mipper

Since I'm a crazy person, and this semester I'm doing a computer architecture class, I've decided to write a MIPS emulator. Originally I was just going to do it in Java using ANTLR, and indeed that's what I spent Saturday on, but then I figured how cool would it be if I could throw the emulator up on Google App Engine once I was done. But App Engine only supports Python, so now I have to rewrite it in Python, which is what I spent Sunday on.
ANTLR has a python output target, but it's not fully supported and I'm afraid of it, so I decided to just roll the parser/lexer myself; normally I would say "Don't Do That!" but MIPS (or any asm) is pretty simple--that is, doesn't require complex parsing algorithms, so it can reasonably be done by hand without much of a fuss.
So now the lexer and parser are done, and I can merrily digest MIPS assembly code; what remains is to specify the behavior. I can do some of that now... but I still have some things to learn about MIPS behavior before I can complete my emulator. I don't think the emulator itself is so hard as figuring out how to shoe-horn it into app engine when I'm done, particularly since I have zero prior experience with Python or Django.
Some comments on Python: When I think Python, I think Haskell-Ruby. The indentation-matters approach is totally Haskell, and so are the tuples and list comprehensions, while the dynamic typing and scriptyness is Ruby. Lambdas are Haskell-Ruby, and the tuple-unwrapping is kindof like Haskell's pattern matching (though of a lesser magnitude).

0 comments: