COMP8830 System Architecture Lecture 2 Notes
Instructions, Numbers & Logic - Part I
Introduction
- This lecture provides an outline understanding of the operation of CPUs and memory in a stored-program (Von Neumann) computer.
- Covers fetch-execute cycle, simple instructions, memory addressing, and CPU registers.
- Explains how to read, write, and inter-convert numbers between bases 10, 16, 8, and 2, including conventional notations.
Key Milestones in AI and Computing
- AlphaGo: In a milestone for artificial intelligence, AlphaGo beat a human Go champion.
- Deep Blue: In 1996, Deep Blue was the first machine to win a chess game against a world champion.
Endgame Databases in Chess
- Endgame databases are generated in advance.
- All endgames with seven or fewer pieces are analyzed completely.
- Seven-piece database requires 200 TB.
The Basic Principles of Computers
- Stored-Program: The lecture references "The Basic Principles of Computers for Everyone" by J. Clark Scott, focusing on the concept of stored-program computers.
- Arithmetic: Chapter 1 and sections 3.1-3.2 of "Computer Organization and Design" by David A. Patterson and John L. Hennessy are suggested for background and arithmetic.
Types of Computers
- Stored-program: Computers that store programs in memory.
- Control-flow: Computers that execute instructions in a sequential manner.
- Digital: Computers that use discrete values to represent data.
- Electronic: Computers that use electronic components.
- Semiconductor-based: Computers that use semiconductors.
Von Neumann Architecture
- Programmable computers have a program (collection of instructions) and data (input and working data).
- In stored-program computers (Von Neumann architecture), both programs and data are stored in the same memory.
- This allows programs to help run/write other programs (self-application or bootstrapping).
- Programs (instructions) are just a kind of data.
Operating Systems
- The operating system is a program for running other programs.
- Before operating systems, human operators were required.
Computer Program Execution
- Programs consist of machine instructions and other data stored in memory.
- CPUs operate in an endless loop: fetch an instruction, execute it, fetch the next instruction.
- Instructions can jump to other parts of the program for repetitions.
- Instructions can be conditional, depending on computed results.
CPU Operation Example
- Instructions are fetched from memory, and operations are performed in functional units such as the ALU (Arithmetic Logic Unit).
- The program counter (PC) keeps track of the current instruction's address.
- Example assembly code (6502 CPU):
LDA $1025
; load a number from memory location 1025ADC $1026
; add to it the number that's in location 1026STA $1027
; store the result to location 1027
Assembly vs Encoded Instructions
- Assembly language is a human-readable notation.
- When running, instructions are encoded as numbers.
- The processor reads these encoded instructions from memory.
- The PC (program counter) is a special register that points at the current instruction.
Memory Addresses
- Cells in memory are numbered sequentially, with each cell's number being its address.
- The program counter holds the address of the current instruction.
Representing Numbers
- Digital electronics encode numbers in a discrete and symbolic way.
Representing Numbers: Base Systems
- Tally Marks: xoxo |
- Roman Numerals: XII
- Decimal (Base Ten): 12
Decimal Numbers
- The decimal numeral 943 represents:
- 9 hundreds + 4 tens + 3 units
- 9 \times 10^2 + 4 \times 10^1 + 3 \times 10^0
- A digit's significance depends on its position.
- Significance uses powers of 10.
Powers
- x^n means multiply together n copies of x.
- e.g., ten to the power 2 is a hundred
- ten to the power 3 is a thousand
- 10^0 = 1 (not 0)
- 1 is the "do nothing" of multiplication.
Powers and Bases
- In base 8, "100" means sixty-four:
- 1 sixty-four + 0 eights + 0 units
- 1 \times b^2 + 0 \times b^1 + 0 \times b^0
Binary Numbers
- What number does the binary numeral 101010 represent?
- 32s + 16s + 8s + 4s + 2s + 1s
- 1\times32 + 0\times16 + 1\times8 + 0\times4 + 1\times2 + 0\times1 = 32 + 8 + 2 = 42
Hexadecimal (Base 16)
- Programmers often use base 16 (hexadecimal).
- Use letters A, B, C, D, E, F for digits ten to fifteen.
- Twelve is C, Forty-two is 2A, etc.
Why Hexadecimal?
- Low-level programming sometimes involves individual wires or binary digits.