LMC KS4.pdf - The Little Man Computer Interface 1 Assembly Language goes here 2 Click ʻCompileʼ 3 Instructions appear as 3-digit opcodes here 4 You

LMC KS4.pdf - The Little Man Computer Interface 1 Assembly...

This preview shows page 1 - 5 out of 13 pages.

The Little Man Computer - Interface 1. Assembly Language goes here 2. Click ʻ Compile ʼ 3. Instructions appear as 3-digit opcodes here 4. You can RUN the program, watch it run SLOWly or STEP through the instructions one-by-one 5. As the program runs, you can see what is happening in here
Image of page 1
Little Man Computer - Input, Storage and Output Type in the following mnemonics, click compile and the following opcodes should appear in the memory: Line By Line INP <-- Prompt the user for an input [stored in accumulator temporarily] STA first <-- Store the answer [currently in accumulator ] in a variable called first INP <-- Prompt the user for an input [stored in accumulator temporarily] STA second <-- Store the answer [currently in accumulator ] in second LDA first <-- Load the number in variable first back into the accumulator OUT <-- Put the contents of the accumulator into the out-box LDA second <-- Load the number in variable second back into the accumulator OUT <-- Put the contents of the accumulator into the out-box HLT <-- End of program first DAT <-- Declare that first is data [i.e. a variable] second DAT <-- Declare that second is data [i.e. a variable] The LMC compiler (technically an assembler) converts each mnemonic into an opcode . INP <-- 901 [Input] STA first <-- 309 [Store in memory address 09] INP <-- 901 [Input] STA second <-- 310 [Store in memory address 10] LDA first <-- 509 [Load the data from memory address 09] OUT <-- 902 [Output] LDA second <-- 510 [Load the data from memory address 10] OUT <-- 902 [Output] HLT <-- 0 [End of program] first DAT <-- [Declare first as a variable] second DAT <-- [Declare second as a variable]
Image of page 2
Points to Note The LMC is not case sensitive. It is a good idea to write mnemonics and variables using different cases to make it easier to read, but the compiler does not notice the difference. Variables are declared at the end of the program, rather than the start. This is so the compiler can assign memory addresses immediately after the program instructions - it doesn ʼ t know which addresses are free initially. If there is an error in the program then the compiler will fail and the code will be lost. It is therefore a good idea to copy (CTRL-C) the program before you compile. This is especially true with more complex programs. Each mnemonic is converted to one opcode - there is a 1:1 relationship. This is one of the major differences between an assembler and a compiler. Step Through By clicking the step button the program will execute one line at a time. You can watch the following boxes to see how the registers inside the processor work. Accumulator <-- Temporarily stores the most current piece of data Program Counter <-- Keeps track of which instruction to carry out next MEM Address <-- Points to the currently addressed memory block MEM Data <-- Loads the contents of the addressed memory In-Box <-- Used for data input Out-Box <-- Used for data output
Image of page 3
Little Man Computer - Addition and Subtraction To add or subtract, load a number into the accumulator and add or subtract number from memory: Line By Line INP <-- Prompt the user for an input [stored in accumulator temporarily] STA first
Image of page 4
Image of page 5

You've reached the end of your free preview.

Want to read all 13 pages?

  • Fall '15
  • NOT

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors