The "Little Man" Computer

Although it is completely inaccurate, it is sometimes convenient to imagine a computer's processing as if it were being managed by a "little man" inside the computer. This (imagined) "little man" behaves following an extremely rigid routine and never performs outside that routine.

An LMC (Little Man Computer) can be imagined to have certain resources available for the little man to use: input and output "trays", a calculator, a collection of numbered "mailboxes", and a counter to keep track of which mailbox the "little man" should look in for his next instruction.

Click the image to get a larger version

LMC Components

LMC Instruction Cycle

The "little man" continuously repeats the following sequence of three major activities:

  1. Instruction Fetch

    As a first step in the fixed routine, the "little man" must get the instruction telling him what he should do next.

    1. he reads and remembers the Mailbox number currently displayed as the Counter value
    2. he goes over to the Mailbox with the Mailbox number that he is remembering, reads the 3 digit value in that Mailbox, and remembers it as the current Instruction value (forgetting any previous Instruction value that he might have been remembering
  2. Counter Increment

    The incrementing of the Counter must occur before instruction execution, as will become obvious when we look at instructions whose execution modifies the value in the Counter.

    1. the "little man" pushes a button which increments the Counter value so that it contains the Mailbox number of the sequencially next Mailbox.
  3. Instruction Execution

    1. the "little man" compares the first digit of the Instruction value that he is remembering with the list of values in the "Instruction Set Table" to find out what he should do.
    2. he then follows the directions given in the Instruction Set Table that correspond to the first digit of the Instruction value.

These three major activities are called: Fetch, Increment, and Execute. Every computer does this.

The "Little Man Computer" Instruction Set

In order to know what should be done for any single instruction, the "little man" compares the first digit of whatever Instruction value he is currently remembering with a list of values in an Instruction Set Table and then performs what ever action is indicated in the table next to the matching code.

Instruction Format

Every instruction in the LMC is encoded as a 3 decimal digit number

The "No-Match" Problem

How does the "little man" handle instructions that are not on his Instruction Set Table? Notice that any value beginning with "81" has no specified action. "555", "666", "777" and others are not there either. The "little man's" actions (and the actions of a real CPU) are undefined when an unknown instruction code is seen. Windows machines blue-screen with "invalid instruction" when this happens. It is the programmer's responsibility to ensure that this never happens.

Access an online simultaor here: Little Man Computer Simulator

Download the pdf booklet for the old OCR coursework (A452) here: Little Man Computer Simulator Instructions you can attempt the exercise once you have followed the tutoirals.