1 / 8

Using the LMC

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.

sasha
Download Presentation

Using the LMC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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.

  2. Getting Started Your teacher will explain where to find the LMC • Clear the Message Box and all of the LMC mailboxes - click the "Clear Messages" button and the "Clear" button if necessary. • Copy the three-line program into the Message Box • Click on the "Compile Program" button. • Click on the "Run" button. • When prompted, enter a three-digit number in the "In-Box", and press the "Enter" button. Program: INP OUT HLT

  3. 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!

  4. Learning about theLittle Man Computer (LMC)

  5. 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.

  6.  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) INBOX 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. 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. The LMC model is based on the concept of a little man locked in a small room.

  7. Execution Cycle 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). INBOX OUTBOX

  8. OUT INP SUB ADD Phew... STA LDA HLT 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.

More Related