HTMT_NNC_C5.pps

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

• 52

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

Chapter 5 LC3 Programming

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

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.

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

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

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?
• Spring '16
• dennis

### What students are saying

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

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

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

Dana University of Pennsylvania ‘17, Course Hero Intern

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

Jill Tulane University ‘16, Course Hero Intern