On creating an ad hoc assembly interpreter to aid studying

&Hello Folks,

I am a CS student on my first year. I've been reading LtU for some years already and obviously most of the topics here are way beyond my current knowledge. This is my first post detailing something I did which I am kinda proud of.

At my university we have a chair called "computer architecture;, in this class they teach us some assembly language for a non-existant x86 machine. We use the SIMx86 simulator for our exercises. In this university we have two examinations per chair and one extra final examination in case you failed passing with the previous two. The second examination was composed only of assembly language questions.

My problem was that I skipped (yes, true) the assembly language classes trusting I could learn it later but when I went to study, I discovered that SIMx86 would only run on windows machines and I have a mac.

It was the night before the examination and I decided on a bold course of action, I decided to code my own assembler interpreter, an ad hoc solution, just good enough to run the exercises we learned. In about five hours, I ended with this design:

Cute X86 GUI

I've called it CuteX86 and implemented only the subset of assembly I needed for my exercises. I've added a debugger that allowed me to run my source step by step inspecting the "memory".

It is not a solution or a product, it is just a tool that I built to aid myself studying. I've created it using Runtime Revolution language which is a "successor" of old Apple HyperCard.

The implementation is really easy, the code is stored in memory as a string and is executed line by line, instead of parsing the whole source and doing a real job, I analyze each executing line converting it to the appropriate Runtime Revolution code to be executed in runtime. This code calls a big switch statement where all the instructions are implemented. There are four register and minimal memory access. I know this is not the proper way of building interpreters but this was not a general purpose tool, it was a way for me to learn assembly so I could pass the examination and not waste my tuition.

I've finished it 2:00 AM and studied till 7:00 AM, took the examination at 8:00 AM and actually passed the thing! (thats why I am happy). By building my own interpreter, I had a deeper knowledge of what was actually happening than my peers, in the end, I could do the examination just by thinking how my code would process something.

Now I am sharing this interpreter with the other students, and even integrated a simple "source code hosting" portal into it so that we can share code.

I always loved computer languages, just bought myself the dragon book, SICP and The Art of Computer Programming Vol 1. Someday I may just be able to write real languages :-)

PS: I am specially proud of my jumping routines!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Every online community needs some curmudgeonly old-timer to scare off new folks. As curmudgeonly as I am, I'm usually not that guy, but today I think I'll take a similar role.

This belongs on a personal blog and not here.

(I know... weak. I'm not too good at this role.)


Thanks Derek. Somebody had to do it. Now the rest of us can say nice things to André.

André: it sounds like you enjoyed yourself. Now go and learn what a monad is. :-P

make it typed...for LtU

I had to build such an interpreter, complete with pipeline cycles of fetch, decode, etc. I think that is a great way of teaching architecture.

However, to make it relevant to LtU, you may want to add a type system to it :)

and NEXT...

And as long as you're looking at x86 assembly language, I beg you to take a look at this. I promise you won't regret it.


I know there is nothing terribly constructive about a "me too" comment... but yes - get thee to that thread! It's an awesome learning tool!