# The Little Man Computer

This is the Little Man Computer, or LMC. It’s an instructional model of a computer, created around 1965. It models a simple Von Neumann architecture, with all the basic features of a modern computer. You can program the LMC using ‘machine code’. Machine code is normally binary numbers that represent instructions to the computer. However, with the LMC, you use denary numbers.

This is the Little Man Computer, or LMC. It’s an instructional model of a computer, created around 1965.

It models a simple Von Neumann architecture, with all the basic features of a modern computer. You can program the LMC using ‘machine code’. Machine code is normally binary numbers that represent instructions to the computer. However, with the LMC, you use denary numbers.

On the left-hand side of the image, you can see the LMC’s instruction set. The xs are for addresses in RAM. For example, 5xx means load, so 550 would be the instruction to load the number in address 50 into the accumulator.

Here’s how you can write a little program using machine code. You start by placing two numbers into RAM. In address 60, you will put the number 5, and in address 61, the number 3. The program itself is going to start at address 0.

You want the program to begin by loading the number in address 60. So, the first instruction must be 560, which you put into address 0.

Next, you want to add the number in address 61 to the number in the accumulator. So, the second instruction is 161, which you write in address 1.

To finish off, you store the output of the calculation: you are going to put it in address 62. So, the instruction 362 is put into address 2.

Here’s a close-up of the finished program and data.

Run the program and see what happens…

• The program counter is currently at 0. So the instruction at address 0 is fetched and the program counter incremented.

• By decoding the instruction 560, the computer now knows to fetch the value at address 60. This is placed in the accumulator.

• It now fetches the next instruction and the program counter is incremented again. The instruction 161 now needs to be decoded.

• That means fetching the number at address 61, placing it into the accumulator, and then sending both numbers to the ALU, which adds them together. The result is 8, which is stored in the accumulator.

• The instruction at address 2 is now fetched, which is 362.

• This is decoded as a store instruction, so the number from the accumulator is taken and stored in address 62.

• Finally, the computer goes to the instruction at address 3, which is 000. This is the machine code for ‘halt’, so the program stops. It has successfully added two numbers and stored the result.

## Little Man Big Possibilities

Even though the Little Man Computer only has ten instructions in its instruction set, you can still create quite complicated programs for it.

Here is a program with sixteen instructions.

The first instruction 901, fetches some input from the user. I’m going to input the number 5.

This program would take about 10 minutes to run at the speed of the simulations above, so instead, here is a speeded-up version so that you can see the final output.

## Branching

You’ll notice that as the program runs, the program counter sometimes goes back to a lower number. This is an example of branching. Sometimes an instruction changes the program counter, so the program goes back to an earlier instruction. This enables a sequence of instructions to be repeated a number of times.

If you look at the final output of this program, you can see that the number is 25. In fact, this program squares the number that was input by the user. As I input 5, the final output is 5 × 5 = 25.

#### How Computers Work: Demystifying Computation

Created by

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.