Model of a Computer

From Notes
Jump to navigation Jump to search

Tuesday, August 30, 2010

Storage of Data

Data represented in bits

01010001 can be 1,010,00110, 812, QASCII

Memory Sequence of locations, one byte ea., 0-indexed

Limits: overflow & roundoff

Types of Storage

  • Cache
  • Main RAM
  • Disk RAM (slower)
  • Tape Sequence


Operations

Simplified model of a computer
  • CPU
  • Arithmetic/logic unit (ALU)
  • Registers (like super fast cache)
  • Control (between Register and RAM

Example: Add number in addr 3 with addr 6, and put result in addr 10

  1. LOAD 3,1
  2. LOAD 6,4
  3. ADD 1,4,3
  4. STORE 3,10

Program Storage

Agreed-upon coding convention:

Interpreted Command ADD (+) r1 (210 = 000000102) r4 (510 = 000001012) r3 (710 = 000001112)
Binary CPU Command 0010 0001 0100 0011


Program execution

  • Instruction register (current execution)
  • Program counter (location in program)

JUMP: (if, while)

  • unconditional and conditional
  • alters Program Counter

Evolution and Abstraction

  1. Machine Language (all in binary)
  2. Assembly Languages (symbols for operators/addresses)
    • Assembler translates to Machine Language
  3. High-level (Fortran, C, Java, C++)
    • Compiler translates to Machine language

Several machine instructions for x = (y+3)/z;


Compilation

Lexical analysis

Break language into Tokens: total = sum + 55.32 → 'total', '=', 'sum', '+', '55.32'

Parsing

Figure out goal of tokens:

  • 'sum + 55.32' → Arithmetic expression;
  • 'total = ...' → Assignment

(Machine) Code Generation

called object code

Write Object Code to disk

Linking

finds references between different files writes new file to disk

Loading

Addresses determined by operating system result is executable