Introduction
The Hardware/ Software Interface Class
Course text book: Computer Systems
The Big Theme
- The hardware/ software interface
- How does the h/w(0s and 1s, processor executing instructions) relate to the s/w (Go programs)?
- Computing is about abstractions (but we can’t forget reality)
- What are the abstractions that we use?
- What do YOU need to know about them?
- When do they break down and you have to peek under the hood?
- What bugs can they cause and how do you find them?
- Become a better programmer and begin to understand the important concepts that have evolved in building ever more complex computer systems.
Roadmap
- Memory and data
- Integers and floats
- Machine code and C
- x86 assembly
- Procedures and stacks
- Arrays and structs
- Memory and caches
- Processes
- Virtual memory
- Memory allocation
- Java/Go vs C
Little theme 1: Representation
- All digital systems represnt everything as 0s and 1s
- The o and 1 are really two different voltage ranges in the electronics
- Everything includes:
- Numbers - integers and floating point
- Character - the building blocks of strings
- Instructions - the directives to the CPU that make up a program
- Pointers - addresses of data objects stored away in memory
- These encodings are stored throughout a computer system
- In registers, caches, memories, disks, etc
- They all need addresses
- A way to find them
- Find a new place to put a new item
- Reclain the place in memory when data no longer needed
Little theme 2: Translation
- There is a big gap between how we thing about programs and data and the 0s and 1s of computers
- Need languages to describe what we mean
- Languages need to be translated one step at a time
- Word-by-word
- Phrase structure
- Grammar
- We know Java/Go as a programming language
- Have to work our way down to the 0s and 1s of computers
- Try not to lose anything in translation!
- We’ll encounter Java/Go byte-code, C language, assembly language, and machine code (for the X86 family of CPU architectues)
Little theme 3: Control flow
- How do computers orchestrate the many things they are doing - seemingly in parallel
- What do we have to keep track of when we call a method, and then another, and then another, and so on
- How do we know what to do upon “return”
- How do we run multiple user programs and let them share a sigle computer and memory
Architecture
Basics of architecture, machine programming
- What is an ISA (Instruction Set Architecture)?
- History of Intel processors and architectures
- C, assembly, machine code
- x86 basics: registers
Translation Impacts Performance
Program lifetime illustration
- The time required to execute a program depends on:
- The program.
- The compiler: what set of assember instructions it translates the program into.
- The instruction set architecture (ISA): what set of instructions it makes available to the compiler.
- The hardware implementation: how much time it takes to execute an instruction.
Instruction Set Architectures
- The ISA defines:
- The system’s state (e.g. registers, memory, program counter)
- The instructions the CPU can execute
- The effect that each of these instructions will have on the system state
General ISA Design Decisions
- Instructions
- What instructions are available? What do they do?
- How are they encoded? (eg 32bits, 64bits)
- Registers
- How many registers are there?
- How wide are they?
- Memory(addressing modes)
- How do you specify a memory location?
x86
- Processors that implement the x86 ISA completely dominate the server, desktop and laptop markets
- Evolutionary design
- Backwards compatibility up until 8086, introduced in 1978
- Added more features as time goes on
- Complex instruction set computer (CISC)
- Many different instructions with many different formats
- But, only small subset encountered with Linux programs
- (as opposed to Reduced Instruction Set Computers (RISC), which use simpler instructions)
- Many different instructions with many different formats
Intel x86 Evolution: Milestones
Name | Date | Transistors | MHz |
---|---|---|---|
8086 | 1978 | 29k | 5-10 |
- First 16-bit processor. Basis for IBM PC & DOS
- 1MB address space
Name | Date | Transistors | MHz |
---|---|---|---|
386 | 1985 | 275k | 16-33 |
- First 32 bit processor, referred to as IA32
- Added “flat addressing”
- Capable of running Unix
- 32-bit Linux/gcc targets i386 by default
Name | Date | Transistors | MHz |
---|---|---|---|
Pentium 4F | 2005 | 230M | 2800-3800 |
- First 64-bit Intel x86 processor, referred to as x86-64
Intel x86 Processors
Machine Evolution | |
---|---|
486 | 1989 |
Pentium | 1993 |
Pentium/MMX | 1997 |
PentiumPro | 1995 |
Pentium III | 1999 |
Pentium 4 | 2001 |
Core 2 Duo | 2006 |
Core i7 | 2008 |
Numbers
Integer & Floating Point Numbers
-
Representation of integers: unsigned and signed
-
Unsigned and signed integers in C
-
Arithmetic and shifting
-
Sign extension
-
Background: fractional binary numbers
-
IEEE floating-point standard
-
Floating-point operations and rounding
-
Floating-point in C
Encoding
- How about encoding a standard deck of playing cards?
- 52 cards in 4 suits
- How do we encode suits, face cards?
- What operations do we want to make easy to implement?
- Which is the higher value card?
- Are they the same suit?
Two possible representation