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

Chapter 13 - Control structures. The main contents of this chapter include all of the following: Conditional constructs, iteration constructs, problem solving using control structures, additional c control structures. | Chapter 13 Control Structures Control Structures Conditional making a decision about which code to execute, based on evaluated expression if if-else switch Iteration executing code multiple times, ending based on evaluated expression while for do-while 13- If if (condition) action; condition action T F Condition is a C expression, which evaluates to TRUE (non-zero) or FALSE (zero). Action is a C statement, which may be simple or compound (a block). 13- Example If Statements if (x 13- More If Examples if (0 13- If’s Can Be Nested if (x == 3) if (y != 6) { z = z + 1; w = w + 2; } if ((x == 3) && (y != 6)) { z = z + 1; w = w + 2; } is the same as. 13- Generating Code for If Statement ; if (x == 2) y = 5; LDR R0, R6, #3 ; load x into R0 ADD R0, R0, #-2 ; subtract 2 BRnp NOT_TRUE ; if non-zero, x is not 2 AND R1, R1, #0 ; store 5 to y ADD R1, R1, #5 STR R1, R6, #4 NOT_TRUE . ; next statement 13- If-else if (condition) action_if; else action_else; condition action_if action_else T F Else allows choice between two mutually exclusive actions without re-testing condition. 13- Generating Code for If-Else if (x) { y++; z--; } else { y--; z++; } LDR R0, R6, #3 BRz ELSE ; x is not zero LDR R1, R6, #4 ; incr y ADD R1, R1, #1 STR R1, R6, #4 LDR R1, R6, #5 ; decr z ADD R1, R1, #1 STR R1, R6, #5 JMP DONE ; skip else code ; x is zero ELSE LDR R1, R6, #4 ; decr y ADD R1, R1, #-1 STR R1, .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.