Little Man Computer interpreter in Ruby

Today I wrote a Little Man Computer interpreter. I’m quite pleased with it.

For those who don’t know (almost everybody?), Little Man Code is a simple assembly-like language for teaching students. For example:

00 901
01 310
02 901
03 110
04 902
05 000

Which can be written in shorthand as (assume -- is comment syntax—which it isn’t):

00 INPUT  -- Get input and put it in the accumulator
01 STO 10 -- Store it in address 10
02 INPUT  -- Get input and put it in the accumulator
03 ADD 10 -- Add the contents of 10 to what's in the accumulator
04 OUTPUT -- Output what's in the accumulator
05 STOP   -- Stops execution

Very simple. We’re using it in Computer Architecture and Systems Software 2 (the return of the compiler?). I wrote 20 lines of it for coursework. And I’ll write some more of it.

Anyway, here’s my interpreter complete with examples and such: lmci_0.1.zip.

Even though it won’t be very useful to very many people, at least I had fun with it. And I learnt from it.

3 Responses to “Little Man Computer interpreter in Ruby”

  1. Lithium x Says:

    It isnt very usful to me holizz infact i beelive that chease would be more useful to you. x

  2. stephen Says:

    what is the command to divide in the little man computer

  3. Holizz Says:

    There isn’t one. But it’s something to think about.

Leave a Reply

You must be logged in to post a comment.