tailieunhanh - Lecture Introduction to computing systems (2/e): Chapter 6 - Yale N. Patt, Sanjay J. Patel

Chapter 6 - Programming. This chapter presents the following content: Systematic decomposition; the three constructs: sequential, conditional, iterative; LC-3 control instructions to implement the three constructs; the character count example from chapter 5, revisited; debugging operations. | Chapter 6 Programming 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-2 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! 6- 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. 6- 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. 6- Three Basic Constructs There are three basic ways to decompose a task: 6- Sequential Do Subtask 1 to completion, then do Subtask 2 to completion, etc. 6- Conditional If condition is true, do Subtask 1; else, do Subtask 2. 6- Iterative Do Subtask over and over, as long as the test condition is true. 6- 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 . | Chapter 6 Programming 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-2 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! 6- 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. 6- Problem Statement Because problem .

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.