
Ch. 9: Executing Instructions
- Computer Instructions.
- While running, computers follow instructions literally.
- No creativity, imagination or intuition.
- No will; no intentions, desires, purposes or goals.
- No sense of humor.
- No “common sense”.
- No sense of proportion or reasonableness.
- No notion of context.
- Instructions are very small.
- Instructions are unambiguous.
- Decide if 5 is less than 6.
- Don't decide if grits are better than oatmeal.
- Computers follow clear rules; they do not exercise judgment.
- Fetch-execute cycle. Constantly repeats:
- Instruction Fetch (IF).
- Instruction Decode (ID).
- Data Fetch (DF).
- Instruction Execution (EX).
- Result Return (RR).
- Computer Anatomy.
- Memory: Numbered mailboxes.
- Addresses.
- Values.
- Limited capacity.
- Arithmetic and Logic Unit.
- Arithmetic.
- Comparisons.
- Logical ops: And, Or, etc.
- Input and output.
- Interface devices: Display, keyboard, mouse, etc.
- Storage devices: Disks, etc.
- Control.
- Follows the program.
- Tells the others what to do.
- Central Processing Unit (CPU) = ALU + Control Unit.
- Instruction execution.
- Instructions are stored in memory.
- Control unit contains a program counter (PC) holding address
of the next instruction.
- Instructions must be brought into the CPU for execution.
- ALU operates on values in registers in the CPU.
- Data must be moved between registers and memory.
- Example instruction: ADD 800, 428, 884
|
|  Instruction Fetch |
 Instruction Decode |
|
|  Data Fetch |
 Execute |
|
|  Result Return |
- Clock
- Periodically generates a pulse to make the CPU
do the next thing.
- Clock period: Time between pulses.
- Clock rate.
- Number of periods per second.
- Reciprocal of the period.
- Units.
- Hertz (Hz): Cycles/second.
- Megahertz (MHz): Millions of cycles/second.
- Gigahertz (GHz): Billions of cycles/second.
- Traditionally, each clock is one step of the fetch-execute cycle.
- Newer approach is to overlap.
- Called pipelining.
- More like an assembly line.
- Programs.
- Constructed from a large number of small instructions.
- Each instruction is coded as a number.
- Example is assembly language: op arg1, arg2, arg2.
- High-level languages: a = a + b;
- Most programs.
- Translated using a compiler:
- Application programs require services from the operating system.
- Memory management. Usually virtual memory.
- Operating devices.
- Creating files.
- Running programs and keeping them apart.
- Programmers reuse existing code.
- Programs evolve.
- Libraries provide procedures for common operations.
- Memory sizes. When is a thousand not a thousand?
- Byte: 8 bits.
- Each byte stores one character.
- Four bits: nibble.
- Kilobyte = 210 bytes = 1024 bytes.
- Megabyte = 220 bytes = 10242 bytes.
- Gigabyte = 230 bytes.
- Integrated Circuits.
- Miniaturization.
- Integration.
- Whole device created at once.
- Cheaper.
- More reliable.
- Manufacture: Photolithogoraphy.
- Photoresist is exposed to UV through a mask, leaving a shadow.
- Acid washes exposed photoresist, exposing the layer below. The
exposed material is removed by hot gasses.
- Remaining resist is removed.
- Silicon is doped to so it can function as a transistor.
- Additional layers and wires are deposited.
- Transistors: Controlled switches.
- Connect transistors to compute combinations.