Little Man Computer
Little Man Computer
Little Man Computer
The Little Man Computer consists of a closed room, in which the Little Man lives. The
Little Man can interact with the external world through 2 windows, one called "Input"
through which he can receive instructions and another called "Output" through which
he can send out messages. Inside the room, the little man has access to 100
mailboxes (storage locations), an accumulator (basic calculator) and a counter.
Finally, he has a little corner to relax. See picture below.
The job of the little man is to execute programs from the memory, one step at a time.
The little man has a counter to keep track of the steps. When asked to execute a
program, the Little Man goes to the memory location '00' and starts by executing the
instruction located there. Once he is done, he increments the counter and proceeds
to the next memory location and so on till he is asked to relax. All data and
instructions are in the form of 3 digit numbers. The first digit represents an instruction
and the last 2 digits can specify a memory location, depending on the instruction.
Components & Physical Layout
The Little Man can change the number in the instruction counter (usually by
incrementing, but sometimes by replacement), and the user of the LMC can reset the
Instruction Counter to 00 using the start button.
Calculator:
Performs simple arithmetic (addition and subtraction only), and used for temporary
storage of a single three digit number. Its display is limited to three digits.
The calculator has ten numerical keys (0-9), and two operation keys (+ and -).
The calculator also has two lights which can be seen by the Little Man. One of these
lights turns on whenever the number being displayed is exactly ZERO. The other light
turns on whenever the number being displayed is positive (the number zero is
considered a positive number). Thus when zero is displayed on the calculator, both
lights will be on. These lights are sometimes referred as flags.
Mailboxes:
Mailboxes are identified by two-digit numbers (00 - 99) and each can hold a single
slip of paper containing a single three digit number (either data or instruction).
Apart from the reset button, all communication between the LMC and the outside
world takes place using 3-digit numbers via In or Out baskets (trays).
Operation
We would like the LMC to do some useful work, so we define a small group of
instructions that he can perform. The 3 digit numbers are used to give instructions to
the Little Man.
The first digit of it is used to tell which operation to perform (opcode). If the operation
requires the LM to use a particular mailbox, we can use the last two digits to specify
the mailbox address that the Little Man is required to store / retrieve data, or to go to.
• Op code
325 – Operation code
– Arbitrary mnemonic
operation code mailbox address
(opcode) (operand) • Operand
– Object to be manipulated
• Data or
• Address of data
Instruction Set
mnemonic meaning opcode operand
add content of address xx to
1xx ADD 1 xx
calculator value
Arithmetic
subtract content of address xx
2xx SUB 2 xx
from calculator value
store calculator value into
3xx STO 3 xx
address xx
Data Movement 4xx DAT 1 store the value xx into calculator 4 xx
load content of address xx into
5xx LDA 5 xx
calculator
move data from in basket to
901 IN 9 01
calculator
Input / Output
move data from calculator to out
902 OUT 9 02
basket
set the instruction counter to xx,
6xx BR thus effectively jump to the 6 xx
instruction in address xx
IF the calculator value is zero,
THEN set the instruction counter
7xx BRZ 7 xx
Branching to xx, thus effectively jump to the
instruction in address xx
IF the calculator value is positive,
THEN set the instruction counter
8xx BRP 8 xx
to xx, thus effectively jump to the
instruction in address xx
Machine Control
000 STP / COB stop - the Little Man rests 0 ignore
(coffee break)
A user can write programs using the instructions above and loads it into the Little
Man Computer's memory (i.e. the mail boxes) for execution.
1
This instruction (DAT) is added by us as needed. (R.T.Sirmen)
Executing a Program
The companioning Excel simulation can be used for writing and executing programs.
To actually run an LMC program we must carry out the following steps:
1. Load the instructions into the mailboxes, starting with mailbox 00.
2. Place the data to be used by the program in the IN basket, in the order in which
the program will use these data.
3. Press the RESET / START BUTTON to set the Instruction Counter to 00 and also
to wake the Little Man up. Then;
Fetching:
• The execution portion of each instruction is, of course, different for every instruction.
• However, even here, there are many similarities.
• The load instruction is typical.
If you check over the guidelines and organization just described, you will observe
that the LMC is an example of a von Neumann architecture.
• The LMC provides a model of the workings of a computer.
• The LMC works by following simple instructions, which are described by
numbers.
• Some of these instructions cause the LMC to change the order in which
instructions are executed.
• Both data and instructions are stored in individual mail slots. There is no
differentiation between the two except in the context of the particular operation
taking place.
• The LMC follows the fetch-execute cycle.
• Normally the LMC executes instructions sequentially from the mail slots except
when he encounters a branching instruction.
The LMC and a real Computer
The relationship between the LMC model and a physical computer is as
follows:
- The Little Man himself is like the control unit of the CPU
Little Man CU
Mailboxes RAM
- The calculator represents the Arithmetic Logic Unit (ALU) of the CPU
Calculator ALU
- The input tray represents the various input devices connected to the CPU,
which include keyboard, mouse, and so on
In basket Input devices
- The output tray represents the various output devices connected to the
CPU, which include monitors, speakers, and so on
start
input 1st #
store # in 99
input 2nd #
add # in 99
output
stop
99 holds data
Subtract 2 numbers
start
input 1st #
store # in 10
input 2nd #
subtract # in 10
output
stop
10 holds data
Find positive difference of 2 numbers
start subtract # in 10
input 1st #
result load # in 10
>= 0 F
store # in 10
T subtract # in 11
output
input 2nd #
store # in 11 stop