These are all your mailboxes (1-100). 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. Getting Started.
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.
Your teacher will explain where to find the LMC
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.
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.
and a resettable counter known as the Program Counter. In the CPU this is known as the control unit.
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.
MAILBOXES (numbered 1-100)
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
Furthermore, there are two mailboxes at the other end labeledINBOX and OUTBOX which are used for receiving and outputting data.
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.
The LMC model is based on the concept of a little man locked in a small room.
MAILBOXES (numbered 1-100)
1. Little Man checks the Program Counter for the mailbox number that contains a program instruction
2. Little Man then fetches the instruction from the mailbox with that number (eg: 006).
3. Little Man goes back to Pgoram Counter and adds 1 to the Program (so it would be 007).
4. Little Man decodes the instruction he received from the mailbox (eg: “get data from mailbox 043”).
5. Little Man then fetches the data from the mailbox he’s been told (eg: box number 043 in this case)
6. Little Man then executes the instruction in that step (eg: fetch some data from the “outbox”)
7. Little Man then goes back to the mailbox (in this case 043) and puts the data he fetched into it..
8. The Little Man is then told to either continue (repeat the cycle) or HALT (stop).
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:
ADD: Adds the value stored in mailbox XX to whatever value is currently on the accumulator (calculator)
SUB: Subtracts the value stored in mailbox XX from whatever value is stored on the Accumulator (calculator)
STA: STORE the contents of the accumulator (calculator) into mailbox XX. This removes whatever was in the mailbox before.
LDA: LOAD the value from mailbox XX and enter it into the accumulator (calculator)
INP: “Input” – Go to the inbox, fetch the value from the user (you type in a number) and put it in the accumulator (calculator).
OUT: “Output” – Copy the value from the accumulator (calculator) to the OUTBOX.
HLT: “Halt” – Stops the whole cycle.