Using the LMC This is where you write

  • Slides: 8
Download presentation
Using the LMC This is where you write your instructions (code). This is where

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

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

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)

Learning about the Little Man Computer (LMC)

What is it? The Little Man Computer models a very simple computer system. It

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.

Furthermore, there are two mailboxes at the other end labeled INBOX and OUTBOX which

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 MAILBOXES (numbered 1 -100) 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. The LMC model is based on the concept of a little man locked in a small room.

8. The Little Man is then told to either continue 1. Little Man checks

8. The Little Man is then told to either continue 1. Little Man checks the Program Counter for the 2. Little Man then fetches the instruction from the 3. Little Man goes back to Pgoram Counter and adds 1 4. Little Man decodes the instruction he received 5. Little Man then fetches the data from the mailbox 6. Little Man then executes the instruction in that 7. Little Man then goes back to the mailbox (in this mailbox number that contains a program instruction mailbox with that number (eg: 006). to the Program (so it would be 007). from the mailbox (eg: “get data from mailbox 043”). he’s been told (eg: box number 043 in this case) step (eg: fetch some data from the “outbox”) case 043) and puts the data he fetched into it. . (repeat the cycle) or HALT (stop). INBOX OUTBOX MAILBOXES (numbered 1 -100) Execution Cycle

A T S SU Phew. . . H LT LDA B When shown like

A T S SU Phew. . . H LT LDA B When shown like that it can seem very complicated. In practice the coding for this is very simple as there a limited number of commands the LMC can cope with. Here are some of them: INP: “Input” – Go to the inbox, fetch STA: STORE the contents of the ADD: Adds the value stored in mailbox LDA: LOAD the value from mailbox XX OUT: “Output” – Copy the value from SUB: Subtracts the value stored in the value from the user (you type in a accumulator (calculator) into mailbox XX to whatever value is currently on HLT: “Halt” – Stops the whole cycle. the accumulator (calculator) to the mailbox XX from whatever value is and enter it into the accumulator number) and put it in the accumulator XX. This removes whatever was in the stored on the Accumulator (calculator) the accumulator (calculator) OUTBOX. mailbox before. (calculator).