Lecture Introduction to computing systems: 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 Problem solving Debugging Problem solving Start with systematic decomposition of problem “top-down” analysis stepwise refinement Algorithms must have properties of: finiteness completeness definiteness computability 6 - Structured programming Three control structures: Sequential This is the default Conditional Branching or decision-making Iteration Loops 6 - Implementing the control structures Sequential Conditional Iterative 6 - Stepwise refinement illustrated Character count algorithm: statement of problem & first level of refinement 6 - Stepwise refinement (cont.) 2nd & 3rd levels 6 - Stepwise refinement (cont.) Final level 6 - Debugging A debugging tool provides (at least) the ability to: Set values to registers & memory locations enter as hex, decimal or binary values Execute instructions one at a time, or in small groups Run will set the program running Step causes a fixed number of instructions to be executed (often used to “single-step” through part of a program) Stop execution when desired Breakpoints allow the user to set points at which execution will halt & wait for a new “Run” instruction Examine the contents of registers and memory locations at any point 6 - Debugging example A program to find the first 1 in a 16-bit word 6 - Debugging example (cont.) Oops! We have an infinite loop! Setting a breakpopint at location x3007 & repeatedly running the code shows that the loop does not trerminate because there is no 1 in the test case number 6 | Chapter 6 Programming Problem solving Debugging Problem solving Start with systematic decomposition of problem “top-down” analysis stepwise refinement Algorithms must have properties of: finiteness completeness definiteness computability 6 - Structured programming Three control structures: Sequential This is the default Conditional Branching or decision-making Iteration Loops 6 - Implementing the control structures Sequential Conditional Iterative 6 - Stepwise refinement illustrated Character count algorithm: statement of problem & first level of refinement 6 - Stepwise refinement (cont.) 2nd & 3rd levels 6 - Stepwise refinement (cont.) Final level 6 - Debugging A debugging tool provides (at least) the ability to: Set values to registers & memory locations enter as hex, decimal or binary values Execute instructions one at a time, or in small groups Run will set the program running Step causes a fixed number of instructions to be executed (often used to “single-step” through part of a program) Stop execution when desired Breakpoints allow the user to set points at which execution will halt & wait for a new “Run” instruction Examine the contents of registers and memory locations at any point 6 - Debugging example A program to find the first 1 in a 16-bit word 6 - Debugging example (cont.) Oops! We have an infinite loop! Setting a breakpopint at location x3007 & repeatedly running the code shows that the loop does not trerminate because there is no 1 in the test case number 6 -

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
7    63    1    20-04-2024
Đã 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.