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

Chapter 11 - Introduction to programming in C. This chapter presents the following content: Our objective, bridging the gap, translating high-level language programs, interpretation, compilation, pros and cons, the c programming language, a simple example A. | Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don’t need to know which register or memory location Provides abstraction of underlying hardware operations do not depend on instruction set example: can write “a = b * c”, even though LC-2 doesn’t have a multiply instruction Provides expressiveness use meaningful symbols that convey meaning simple expressions for common control patterns (if-then-else) Enhances code readability Safeguards against bugs can enforce rules or conditions at compile-time or run-time 11- Compilation vs. Interpretation Different ways of translating high-level language Interpretation interpreter = program that executes program statements generally one line/command at a time limited processing easy to debug, make changes, view intermediate results languages: BASIC, LISP, Perl, Java, C-shell Compilation translates statements into machine language does not execute, but creates executable program performs optimization over multiple statements change requires recompilation can be harder to debug, since executed code may be different languages: C, C++, Fortran, Pascal 11- Compilation vs. Interpretation Consider the following algorithm: Get W from the keyboard. X = W + W Y = X + X Z = Y + Y Print Z to screen. If interpreting, how many arithmetic operations occur? If compiling, we can analyze the entire program and possibly reduce the number of operations. Can we simplify the above algorithm to use a single arithmetic operation? 11- Compiling a C Program Entire mechanism is usually called the “compiler” Preprocessor macro substitution conditional compilation “source-level” transformations output is still C Compiler generates object file machine instructions Linker combine object files (including libraries) into executable image 11- Compiler Source Code Analysis “front end” parses programs to identify its pieces variables, expressions, statements, functions, etc. depends on language

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.