C- Deconstructed.pdf

(5383 KB) Pobierz
www.allitebooks.com
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
www.allitebooks.com
Contents at a Glance
About the Author �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½xi
About the Technical Reviewer �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½xiii
■
Chapter 1: Introduction to Programming Language �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½1
■
Chapter 2: The Virtual Machine and CLR �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½25
■
Chapter 3: Assembly �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½39
■
Chapter 4: CLR Memory Model �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½61
■
Chapter 5: CLR Memory Model II �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½87
■
Chapter 6: CLR Execution Model�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½111
■
Chapter 7: CLR Execution Model II �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½131
Index �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½153
v
www.allitebooks.com
Chapter 1
Introduction to
Programming Language
The basic operational design of a computer system is called its architecture. John von Neumann, a pioneer in
computer design, is credited with the architecture of most computers in use today. A typical von Neumann system has
three major components: the central processing unit (CPU), or microprocessor; physical memory; and input/output
(I/O). In von Neumann architecture (VNA) machines, such as the 80x86 family, the CPU is where all the computations
of any applications take place. An application is simply a combination of machine instructions and data. To be
executed by the CPU, an application needs to reside in physical memory. Typically, the application program is written
using a mechanism called programming language. To understand how any given programming language works, it is
important to know how it interacts with the operating system (OS), software that manages the underlying hardware
and that provides services to the application, as well as how the CPU executes applications. In this chapter, you will
learn the basic architecture of the CPU (microcode, instruction set) and how it executes instructions, fetching them
from memory. You will then learn how memory works, how the OS manages the CPU and memory, and how the OS
offers a layer of abstraction to a programming language. Finally, the sections on language evaluation will give you a
high-level overview of how C# and common language runtime (CLR) evolved and the reason they are needed.
Overview of the CPU
The basic function of the CPU is to fetch, decode, and execute instructions held in read-only memory (ROM) or
random access memory (RAM), or physical memory. To accomplish this, the CPU must fetch data from an external
memory source and transfer them to its own internal memory, each addressable component of which is called
a register. The CPU must also be able to distinguish between instructions and operands, the read/write memory
locations containing the data to be operated on. These may be byte-addressable locations in ROM, RAM, or the
CPU’s own registers.
In addition, the CPU performs additional tasks, such as responding to external events for example resets and
interrupts, and provides memory management facilities to the OS. Let’s consider the fundamental components of a
basic CPU. Typically, a CPU must perform the following activities:
•
•
•
Provide temporary storage for addresses and data
Perform arithmetic and logic operations
Control and schedule all operations
1
www.allitebooks.com
Chapter 1
■
IntroduCtIon to programmIng Language
Figure
1-1
illustrates a typical CPU architecture.
Figure 1-1.
Computer organization and CPU
Registers have a variety of purposes, such as holding the addresses of instructions and data, storing the result of
an operation, signaling the result of a logic operation, and indicating the status of the program or the CPU itself. Some
registers may be accessible to programmers, whereas others are reserved for use by the CPU. Registers store binary
values (1s and 0s) as electrical voltages, such as 5 volts or less.
Registers consist of several integrated transistors, which are configured as flip-flop circuits, each of which can be
switched to a 1 or 0 state. Registers remain in that state until changed by the CPU or until the processor loses power.
Each register has a specific name and address. Some are dedicated to specific tasks, but the majority are general
purpose. The width of a register depends on the type of CPU (16 bit, 32 bit, 64 bit, and so on).
2
www.allitebooks.com
Zgłoś jeśli naruszono regulamin