1 Fluency with Information Technology7th Edition Chapter 9 Principles of Computer Operations
2 Learning Objectives 1.1 Explain what a software stack represents and how it is used 1.2 Describe how the Fetch/Execute Cycle works, listing the five steps 1.3 Understand the function of the memory, control unit, arithmetic/logic unit (ALU), input/output (I/O) unit , and program counter (PC) 1.5 Describe how large tasks are performed with simple instructions 1.6 Explain the purpose of a complier
3 Computers: An OverviewComputers are used throughout your day we are continually using computation They are laptops, cameras, tablets, MP3 players, desktops, TVs, and all the other electronic devices that we use
4 Computers: The Usual SuspectsProcessor: follows the program’s instructions Operating System: program that performs common operations, and makes your computer a useful device Software: applications or apps Instructions: tell the processor what to do Fetch/Execute Cycle: executes the instructions Memory: stores the data Hardware: the physical parts of the computer
5 A Closer Look: SoftwareWhen you get a new app, it is really a long sequence of bits A team of programmers created the bits but did not type them one by one The program is a series of instructions expressing an algorithm Lines are sparse, with a few symbols each The smallest typo can create a bug A program’s meaning may not usually be clear without specialized training
6 1.1 Software Layers System software is arranged in layersEach layer uses services from the layer below Each layer provides services to the layer above Shared effort: new programs reuse existing work Once written, a feature can be used in many applications To fix a bug or make an improvement, only one place to change
7 Figure 9.2 Software Layers: A Software StackSoftware stack for Windows.NET.
8 1.2 The Instruction Execution Engine and the Fetch/Execute CycleA computer constantly executes instructions, repeated in a never-ending sequence It does this by cycling through a series of operations called the Fetch/Execute Cycle: Get the next instruction Figure out what to do Gather the data needed to do it Do it Save the result Repeat billions of times per secon
9 Figure 9.3 The Fetch/Execute Cycle
10 1.3 Anatomy of a Computer All computers, regardless of their implementing technology, have five basic parts or subsystems: Memory Control unit Arithmetic/logic unit (ALU) Input unit Output unit
11 Figure 9.4 Principal Computer SubsystemsThe five principal subsystems of a computer—the control unit, the memory, the ALU, the input unit, and the output unit—with typical input and output devices shown.
12 The Memory Subsystem Memory stores both the program while it is running and the data on which the program operates Memory is organized as a sequence of labeled containers called locations, each composed of 1 byte (8 bits) Every memory location has an address, the location's number in the sequence Memory locations record or store values, the contents of the containers Memory locations have a finite capacity (limited size); only so much can fit in each container
13 Memory is Stored in BytesA 1-byte memory location can store one ASCII character or a number less than 256 Blocks of four bytes are used as a unit so often that they are called memory words
14 Random Access Memory (RAM)Computer memory is called random access memory (RAM) Random access means that the computer can refer to the memory locations in any order RAM is measured in megabytes (MB) or gigabytes (GB) Lots of memory is need to provide the space required for programs and data
15 The Control Unit SubsystemThe control unit of a computer is where the Fetch/Execute Cycle occurs Its circuitry fetches an instruction from memory and performs the other operations of the Fetch/Execute Cycle on it
16 The Arithmetic/Logic Unit Subsystem“Does the math” A circuit in the ALU can add two numbers, multiply them, compare them, etc. The ALU carries out each machine instruction with a separate circuit The circuit uses logic gates, or simpler circuits that implement operations like AND and OR
17 The Input and Output Units SubsystemThese two components are the wires and circuits through which information moves into and out of a computer A computer without input or output is useless
18 Peripherals Peripherals connect to the computer input/output (I/O) ports They provide input or receive output They are not considered part of the processor They are specialized gadgets that encode or decode information between the processor and the physical world
19 Peripherals: Handling the Physical Part of the OperationKeyboards keystrokes into binary form for the computer Monitors decodes information from the computer’s memory and displays it on a screen Some peripherals are storage devices used by computers for both input and output: USB memory Hard disks/drives
20 Peripherals and Device DriversPeripherals provide only basic physical translation to or from binary signals. Additional information from the computer is needed to make it operate in an "intelligent way" Every peripheral device needs a device driver, software with additional processing that gives the peripheral's input and output its standard meaning and behavior
21 Machine Instructions A computer’s instructions are more primitive than what programmers type Example: ADD 4000, 2000, 2080 Commands the computer to add the numbers stored in memory locations 2000 and 2080 and then store that in the memory location 4000 Computer instructions encode the memory addresses, not the numbers themselves (indirect reference)
22 The Program Counter: The PC's PCA computer determines which instruction it should execute next by using the address of the next instruction Computers use the address (known as the program counter or PC) to keep track of the next instruction It assumes that the next instruction is the next instruction in sequence Because instructions use 4 bytes of memory, the next instruction must be at the memory address PC + 4, so the processor increases the PC by 4
23 The Program Counter: Branching and JumpingNot all instructions are in a strict sequence The instruction may include a memory location (address) to go to next This changes the PC, so instead of going to PC+4 automatically, the computer jumps or branches to the specified location to continue execution from the new address
24 Stepping Through ADD 400, 2000, 2080: Instruction FetchExecution begins by moving the instruction at the address given by the PC (PC 800) from memory to the control unit Bits of instruction are placed into the decoder circuit of the CU Once instruction is fetched, the PC can be readied for fetching the next instruction
25 Figure 9.8 The Processor Before Instruction ExecutionThe processor before executing the instruction in memory location 800.
26 Figure 9.9 Instruction FetchInstruction Fetch: The instruction addressed by the PC is moved from memory to the control unit.
27 Stepping Through ADD 400, 2000, 2080: Instruction DecodeThe Arithematic/Logic Unit (ALU) is set up for the operation The decoder finds the memory address of the instruction's data (source operands) Most instructions operate on two data values stored in memory (like ADD), so most instructions have addresses for two source operands These addresses are passed to the circuit that fetches them from memory during the next step The decoder finds the destination address for the Result Return step and places the address in the RR circuit The decoder determines what operation the ALU will perform (ADD), and sets up the ALU
28 Figure 9.10 Instruction DecodeDecode: The instruction is analyzed and the processor is configured for later steps. The data addresses are sent to the memory unit, the operation (+) is set in the ALU, and the result return address is set.
29 Stepping Through ADD 400, 2000, 2080: Data FetchThe data values to be operated on are retrieved from memory Bits at specified memory locations are copied into locations in the ALU circuitry Data values remain in memory (they are not destroyed)
30 Figure 9.11 Data Fetch Data Fetch: The values for the two operands are fetched from memory and stored in the ALU.
31 Stepping Through ADD 400, 2000, 2080: Instruction ExecuteFor this ADD instruction, the addition circuit adds the two source operands together to produce their sum The sum is held in the ALU circuitry This is where the actual computation is performed
32 Figure 9.12 Instruction ExecuteInstruction Execute: The addition operation is performed.
33 Stepping Through ADD 400, 2000, 2080: Result ReturnResult Return returns the result of the Instruction Execute to the memory location specified by the destination address. Once the result is stored, the cycle begins again
34 Figure 9.13 Result Return Result Return: The answer is returned to the memory, and the program counter's updated value is sent to the memory in preparation for the next fetch.
35 1.5 Many Simple Operations Done QuicklyComputers “know” very few instructions: the decoder hardware in the controller recognizes, and the ALU performs, only about 100 different instructions (with a lot of duplication) There are only about 20 different kinds of operations., like ADD Everything that computers do must be reduced to some combination of these primitive, hardwired instructions Computers achieve success at what they can do with speed, executing many simple instructions per second A rate determined by the computer’s clock, measured in megahertz, or millions (mega) of cycles per second (hertz). A computer with a 1 GHz clock has one billionth of a second—one nanosecond—between clock ticks to run the Fetch/Execute Cycle.
36 Translation A programmer writes source code, such as: this.Opacity += 0.02 The bits the processor needs are known as object code, binary code, or just binary Source code is translated into assembly code, then into binary
37 ADD Opacity, TwoCths, OpacityAssembly Language A primitive programming language Uses words instead of 0s and 1s ADD Opacity, TwoCths, Opacity To convert source code into assembly, the source code must be compiled by a compiler
38 Compilers A compiler is a computer program that translates another computer program into assembler language Each compiled language requires its own compiler Assembly language is converted to machine language by yet another program called an assembler
39 Summary Modern software is written in a language using familiar terms and operations, though they are expressed very briefly; the code relies heavily on the software stack The Fetch/Execute Cycle fetches each instruction (indicated by the PC), decodes the operation, retrieves the data, performs the operation, and stores the result back into the memory This process is hardwired into the control subsystem, one of the five components of a processor Machine instructions do not refer to the data (operands) directly, but rather indirectly. Thus, different computations can be done with an instruction, just by changing the data in the referenced memory locations each time the instruction is executed