HTMT_NNC_C5.pps - Chapter 5 LC3 Programming Solving...

This preview shows page 1 - 11 out of 52 pages.

Chapter 5 LC3 Programming
Image of page 1

Subscribe to view the full document.

4-2 Solving Problems using a Computer Methodologies for creating computer programs that perform a desired function. Problem Solving How do we figure out what to tell the computer to do? Convert problem statement into algorithm, using stepwise refinement . Convert algorithm into LC-3 machine instructions. Debugging How do we figure out why it didn’t work? Examining registers and memory, setting breakpoints, etc. Time spent on the first can reduce time spent on the second!
Image of page 2
4-3 Stepwise Refinement Also known as systematic decomposition . Start with problem statement: “We wish to count the number of occurrences of a character in a file. The character in question is to be input from the keyboard; the result is to be displayed on the monitor.” Decompose task into a few simpler subtasks . Decompose each subtask into smaller subtasks , and these into even smaller subtasks , etc .... until you get to the machine instruction level.
Image of page 3

Subscribe to view the full document.

4-4 Problem Statement Because problem statements are written in English, they are sometimes ambiguous and/or incomplete. Where is “file” located? How big is it, or how do I know when I’ve reached the end? How should final count be printed? A decimal number? If the character is a letter, should I count both upper-case and lower-case occurrences? How do you resolve these issues? Ask the person who wants the problem solved, or Make a decision and document it.
Image of page 4
4-5 Three Basic Constructs There are three basic ways to decompose a task: Task Subtask 1 Subtask 2 Subtask 1 Subtask 2 Test condition Subtask Test condition Sequential Conditional Iterative True True False False
Image of page 5

Subscribe to view the full document.

4-6 Sequential Do Subtask 1 to completion, then do Subtask 2 to completion, etc. Get character input from keyboard Examine file and count the number of characters that match Print number to the screen Count and print the occurrences of a character in a file
Image of page 6
4-7 Conditional If condition is true, do Subtask 1; else, do Subtask 2. Test character. If match, increment counter. Count = Count + 1 file char = input? True False
Image of page 7

Subscribe to view the full document.

4-8 Iterative Do Subtask over and over, as long as the test condition is true. Check each element of the file and count the characters that match. Check next char and count if matches. more chars to check? True False
Image of page 8
4-9 Problem Solving Skills Learn to convert problem statement into step-by-step description of subtasks. Like a puzzle, or a “word problem” from grammar school math. What is the starting state of the system? What is the desired ending state? How do we move from one state to another? Recognize English words that correlate to three basic constructs: “do A then do B” sequential if G, then do H” conditional for each X, do Y” iterative “do Z until W” iterative
Image of page 9

Subscribe to view the full document.

4-10 LC-3 Control Instructions How do we use LC-3 instructions to encode the three basic constructs?
Image of page 10
Image of page 11
  • Spring '16
  • dennis

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