1 / 13

GCSE Computing – the LMC

Candidates should be able to: describe the characteristics of an assembler. GCSE Computing – the LMC. LMC stands for Little Man Computer . The LMC is a CPU simulator that models a simple computer using the von Neumann architecture and memory use

farren
Download Presentation

GCSE Computing – 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. Candidates should be able to: • describe the characteristics of an assembler GCSE Computing – the LMC

  2. LMC stands for Little Man Computer. • The LMC is a CPU simulator that models a simple computer using the von Neumann architecture and memory use • a central processing unit consisting of an arithmetic logic unit and registers • a control unit containing an instruction register and program counter • input and output mechanisms • RAM to store both data and instructions • external secondary storage • The simulation uses the idea of a ‘Little Man’ inside the computer fetching instructions from RAM and executing them. • The LMC can be programmed directly by entering machine code (but in decimal) directly into RAM. • However, the LMC is usually programmed in assembly code. • An assembler then translates the assembly code into machine code (but in decimal) and loads it into RAM. What is the LMC?

  3. RAM consisting of 100 memory addresses (0-99). Each address can hold a decimal format number up to 999. INPUT using a 0-9 digit keypad. OUTPUT using a multi-line display. A PROGRAM COUNTER that stores the address of the next instruction in RAM. An INSTRUCTION REGISTER that stores the OPP CODE of the current instruction. An ADDRESS REGISTER that stores the address part of the current instruction (if it has one). An ACCUMULATOR that stores the results of any calculations. What are the components of the LMC?

  4. As the simulation runs the ‘Little Man’ inside the computer carries out the following steps: • Check the Program Counter to find the RAM address with the program instruction to be fetched. • Fetch the INSTRUCTION from that RAM address. • Increment the Program Counter (so that it contains the RAM address of the next instruction). • Decode the instruction (this might include finding the RAM address for the data it will work on). • If necessary, fetch the DATA from the RAM address found in the previous step. • Execute the instruction. • Repeat the cycle or halt. Programming the LMC

  5. Parts of the LMC – before code is assembled A program in ASSEMBLY LANGUAGE ready to be translated into machine code Memory addresses0-99 OUTPUT, displaying number data output An explanation of the instruction to be executed next INPUT, allowing number data input

  6. Parts of the LMC – after code is assembled The PROGRAM COUNTER The program in ASSEMBLY LANGUAGE without LABELS The INSTRUCTION REGISTER, containing the current INSTRUCTION CODE The contents of the ACCUMULATOR The ADDRESS REGISTER, containing the ADDRESS that the current instruction code refers to

  7. Parts of the LMC – after code is assembled The program in ASSEMBLY LANGUAGE MACHINE CODE instructions stored in RAM DATA stored in RAM DATA

  8. Labels can be used to label a memory address that contains DATA. Being able to refer to the data as a label is much easier than having to refer to the address the data is stored at. • Example: • data1 DAT • Explanation: The memory address where this data is stored is labelled data1. No data would initially be stored at this location. If this was the 7th line of assembly code to be compiled then the label would refer to memory address 6 (RAM addresses start at 0) • data1 DAT 50 • Explanation: The memory address where this data is stored is labelled data1 and stores the data 50. If this was the 7th line of assembly code to be compiled then the data 50 would be stored at memory address 6 (RAM addresses start at 0) • STA data1 • Explanation: The contents of the accumulator would be stored at memory address 6. • LDA data1 • Explanation: The data which is stored at memory address 6 would be loaded into the accumulator. The LMC – using labels with data

  9. Labels can be used to label a memory address that contains an INSTRUCTION. Being able to refer to the label rather than the address of the instruction makes it much easier when using BRANCH instructions such as BRA, BRP and BRZ. • Example: • loop1 INP • Explanation: The memory address where this instruction is stored would be labelled loop1. • BRZ loop1 • Explanation: If the contents of the accumulator were zero, the program would branch to the memory address labelled loop1 and carry out the instruction there. • To achieve this, the Program Counter would be set to the memory address labelled loop1. • If the contents of the accumulator were not zero then the Program Counter would simply be incremented by one. The LMC – using labels with branches

  10. The LMC – how labels are used Labels used with BRANCH instructions Labels used with DATA

  11. After a program is assembled into machine code the Program Counter is always reset to memory address 0. The ‘Little Man’ checks the Program Counter to find the RAM address with the instruction to be fetched (in this case address 0). Here, the instruction 523 is fetched from RAM address 0. The Program Counter is incremented (to RAM address 1). The instruction part (5) is loaded into the INSTRUCTION REGISTER and the address part (23, the RAM address for the data the instruction will work on) is loaded into the ADDRESS REGISTER. The instruction is then decoded. The instruction is executed (5 = LOAD into ACCUMULATOR so the 0 stored at RAM address 23 is loaded into the ACCUMULATOR). Back to step 1 to repeat the cycle until a HALT instruction is reached. Running a program using the LMC

  12. An instruction starting with a 9 (901 or 902) means the instruction is an INPUT/OUTPUT command. • The ‘address’ part of the instruction (01 or 02) decides if the instruction is actually an INPUT or an OUTPUT. • 01 means INPUT - entered using the number keypad and stored in the ACCUMULATOR when the Enter key is pressed. • 02 means OUTPUT – the value stored in the ACCUMULATOR is passed to the OUTPUT box. INPUT and OUTPUT using the LMC

  13. The LMC instruction set NOTE: xx represents a memory address between 0 and 99.

More Related