File

Report
Using the LMC
This is where you write your instructions
(code).
This is where you
can reset and run
your program. If
your program has
an “INP” (input)
command, you
will type it in this
box here.
These are all
your mailboxes
(1-100)
Getting Started
Your teacher will explain where to find the LMC
1. Clear the Message Box and all of the LMC
mailboxes - click the "Clear Messages"
button and the "Clear" button if necessary.
2. Copy the three-line program into the
Message Box
3. Click on the "Compile Program" button.
4. Click on the "Run" button.
5. When prompted, enter a three-digit number
in the "In-Box", and press the "Enter"
button.
Program:
INP
OUT
HLT
What did it do?
The first instruction (INP) asked you to input a number
into the Accumulator (calculator). The Little Man went
to mailbox 1 and found an instruction telling him to go
to the “Input” box and wait for data. When this data
arrived he put it into the Accumulator (calculator).
The second instruction (OUT) was in mailbox 2. The Little
Man went there and was told to take the number from
the Accumulator and copy it to the Outbox.
The third instruction (HLT) was in mailbox 3. The Little
Man went there and was told to stop what he was
doing.
Simple!
Learning about the
Little Man Computer (LMC)
What is it?
The Little Man
Computer models a
very simple
computer system. It
can only cope with a
small selection of
tasks: mostly input,
output, storage and
calculation.
INBOX
In the centre of the room,
there is a work area
containing a simple two
function (addition and
subtraction) calculator
known as the Accumulator.
In the CPU this is known as
the ALU.
Furthermore, there are two
mailboxes at the other end
labeled INBOX and OUTBOX
which are used for receiving
and outputting data.
OUTBOX
The Program Counter is
similar to what a
doorperson uses to keep
track of how many people
have entered a facility -- it
can count up 1, or it can be
reset to 0.
and a resettable
counter known as
the Program
Counter. In the
CPU this is known
as the control
unit.
At one end of the
room, there are 100
mailboxes (memory),
numbered 0 to 99,
that can each contain
a 3 digit instruction.
In your computer this
would be your RAM
The LMC model
is based on the
concept of a
little man locked
in a small room.
Execution Cycle
8. The
1.
2.
3.
4.
5.
6.
7.
LittleLittle
ManMan
checks
goes
decodes
then
isback
fetches
executes
goes
then
the
the
to
back
Program
told
instruction
the
Pgoram
the
to
to
instruction
data
the
instruction
either
Counter
Counter
from
mailbox
he
continue
received
the
from
for
in
and
(in
mailbox
that
the
the
this
adds
mailbox
1
from
he’s
step
case
(repeat
to the
been
(eg:
043)
thethe
Program
number
with
fetch
mailbox
and
told
cycle)
that
puts
(eg:
some
that
(so
(eg:
or
number
box
the
HALT
data
itcontains
“get
would
data
number
from
(stop).
(eg:
data
hebe
a006).
the
fetched
043
from
program
007).
“outbox”)
inmailbox
this
into
instruction
case)
it..043”).
INBOX
OUTBOX
Phew...
When shown like that it can seem very complicated.
In practice the coding for this is very simple as
there are a limited number of commands the
LMC can cope with. Here are some of them:
INP:
STA:
“Input”
STORE– the
Go to
contents
the inbox,
of the
fetch
ADD:
LDA:
OUT:
SUB:
LOAD
Adds
“Output”
Subtracts
the
the value
value
– the
Copy
stored
value
from
the mailbox
value
stored
in mailbox
from
inXX
the
accumulator
value from
(calculator)
the user (you
intotype
mailbox
in a
XX
HLT:
the
mailbox
and
toaccumulator
“Halt”
enter
whatever
XXit
–from
Stops
into
value
(calculator)
whatever
the
theisaccumulator
whole
currently
value
to
cycle.
the
on
is
number)
XX. This removes
and put itwhatever
in the accumulator
was in the
storedthe
onaccumulator
the (calculator)
Accumulator
OUTBOX.
(calculator)
(calculator)
mailbox
(calculator).
before.

similar documents