Presentation is loading. Please wait.

Presentation is loading. Please wait.

Little Man Computer When your program gets “translated to machine code” all 0’s & 1’s The translator must know the language of the program (java) as well.

Similar presentations


Presentation on theme: "Little Man Computer When your program gets “translated to machine code” all 0’s & 1’s The translator must know the language of the program (java) as well."— Presentation transcript:

1 Little Man Computer When your program gets “translated to machine code” all 0’s & 1’s The translator must know the language of the program (java) as well as the language of the cpu – “the instruction set” LMC is a simple instruction set for “toy” computer

2 About The LMC It is a model/illustration of a computer
Created by Dr. Stuart Madnick at MIT in 1965 (he updated it in 1979) A fairly accurate representation of how computers still work today.

3 (Central Processing Unit)
Calculations and other operations performed by: CPU (Central Processing Unit)

4 LMC Model

5 LMC Schematic 00 123 123 01 500 02 199 03 500 04 399 456 05 95 96 97 98 789 99 123 05

6 System Counterparts ALU Input/output interface Control unit
00 123 123 01 500 02 199 03 500 04 399 456 05 Control unit 95 96 97 98 789 99 123 05 Program counter

7 Input/output interface
System Block Diagram CPU Memory ALU Input/output interface Control unit Program counter

8 LMC Instruction Set Layout of Instructions
3 digits (use decimal; idea is similar in binary) Think of memory as storage locations – mailboxes that can hold one slip of paper with 3 digits

9 LMC Instruction Set Interpretation of the 3 digit
1st digit = instruction called the operation code op code for short 2nd and 3rd digits mailbox address (for the most part) eg. 225 means “store into mailbox 25”

10 LMC Instruction Set 1 Load
Reverse of Store: walks to the mbox specified, copies the instruction on the slip of paper and takes it to the calculator and punches the number in. 2 Store walk to calculator, reads the number there, and writes the number on a slip of paper, walks to the mbox specified in the instruction, and puts this slip of paper there (replacing any paper already there

11 LMC Instruction Set 3 Add
walk to mailbox address specified and read the number there; walk to calculator and adds it to the number already in the calculator 4 Subtract similar to add but subtracts 5 Input walks to the in box and picks up the slip of paper having a 3-digit number on it; walks over to the calculator and enters that number

12 LMS Instruction Set 6 Output
walk to calculator, reads the number there, and writes the number on a slip of paper, walks to the out box and puts this slip of paper there 7 Halt stop 800 Skip if Negative walk to calculator; if the value is less than zero then walk to prog. counter and add one to the current value

13 LMS Instruction Set 801 Skip If Zero
walk to calculator; if the value is zero then walk to prog. counter and add one to the current value 802 Skip If Positive walk to calculator; if the value is greater than zero then walk to prog. counter and add one to the current value 9 Jump Tells LMC to change the program counter to the number shown on the address portion

14 A program to add 2 numbers
input store data input add output stop data

15 A program to find positive difference of 2 numbers
00 Input 01 Store 02 Input 03 Store 04 Subtract 05 Skp if Neg 800 06 Jmp 07 Load 08 Subtract 09 Output 600 10 Halt 700 11 Data 12 Data

16 Fetch, (Decode,) Execute Instruction Cycle
Fetch: get the next instruction as indicated by the program counter: goes to mbox address and reads the 3 digit code (the instruction) and then increments the program counter Decode: electronically decode the instruction to determine which operation to perform (not shown in LMC) Execute: perform the instruction Repeat cycle until halt


Download ppt "Little Man Computer When your program gets “translated to machine code” all 0’s & 1’s The translator must know the language of the program (java) as well."

Similar presentations


Ads by Google