VCU INFO300 - Computer Hardware and Software
 
 

The Little Man Computer

  • This is an exercise to illustrate the topics of 'machine cycles', 'instruction sets', and 'machine programming', including the ease of introducting inefficiencies into machine code. br> The text addresses these concepts in the figures starting at 2.6.  Sit with these pages for a while and figure out concepts like: clock, instruction counter, fetch, instruction time, execution time, copying data from memory to registers & the other way, accumulator.  The text doesn't emphasize 'wait states', but that's a good topic to add on, expecially in the wake of the dual & multicore processors becoming common these days.

  • The Little Man Computer

    (Google on 'little man computer' to find other examples, including java applets & flash animations that help illustrate the points.  The paragraphs below describe a similar, non-Flash animated LMC with a somewhat different instruction set...)

    This exercise assumes there's a 'little man' in the computer that does what the ICU and ALU do.

    There is a simple set of 11 instructions for the little man to follow.

    This example follows one in Englander: The Architecture of Computer Hardware and Systems Software, which was the prior text used for this course. It has been adapted by Nottingham University and put on-line as a pdf.

    This is a png we'll use in class to run thru a couple of LMC programs. This is smaller, for the projector...

    RAM is at the right, using a two-digit address to reference 100 memory locations from 0 thru 99. Before the Start Button is pushed to get the Little Man's attention, a program is loaded as 'program data' starting at address 0. RAM can also hold 'plain data' after the program, it being the programmer's responsibility to keep program instructions from being overwritten by data.

    The Instruction Counter is a special register that holds the address of the next instruction to fetch. When the Start button is pushed the, it drops 0 into the first Instruction Cycle just before a bell rings to signal the Little Man to start his Instruction Cycles.

    The 'Register' is a general purpose register used to hold temporary values. The LMC can only do arithmetic on data while they're in the register, so complex calculations, like an average, will need to shuffle data in & out of the register.

    An InBox and OutBox are used for inputting data, up to three digits, and for displaying results as output.

    The instruction set is built in the computer where the Little Man can reference it easily. Some instructions have two parts: the 'Op Code' and an 'Operand'. In the LMC, instructions 1 thru 8 use the last two 'bytes' of a three 'byte' word to reference a memory address. So, '311' means 'Write register contents to memory location 11'.

    The instructor or some volunteer from the class plays the part of the Little Man, who has a lot more to do than the little man in the refrigerator. LM has been trained to follow this Instruction Cycle:

    • Read the Address in the Instruction Counter;
    • Fetch the instruction at that address;
    • Execute the instruction;
    • Increment the Instruction Counter;
    • Repeat.


    The User of the LMC writes the program into RAM, starting at 0, then presses the start button, setting a 0 in the instruction counter and LM to work...

    Here's a program that inputs two numbers and displays the difference between them.  We'll run this in class and work on a more complex program:

    901
    311
    901
    211
    902
    000

    The assignment following it is to sit with a LMC for a while and work out a couple of other programs, maybe even something that does branches and loops.

    Questions on quizzes about this exercise will be to write another program. A simple one like this will get 1 point. A more complex one will be a candidate for 2 points, should use a branching instruction to do something like accumulate a total of entries until the user enters a zero, or count the entries, maybe even average them if you want to obsess on this for a while...