/>
Review
 jbwyatt.com

.. Algorithms become Programs

  • Algorithms are the basis for programs
  • We must translate into the syntax of a HOL
  • Computers ONLY speak binary...
  • Must compile / translate HOL into binary code
  • The binary code actually executes on a computer
  • EVERYTHING is 1s and 0s (why not write code in binary?)
  • Binary code like DNA? Genetic programming?
  • Programs run on computers with their own language
  • bit, byte, kilobyte, megabyte, etc...
  • 2 log n - how much can u store in a byte?
  • CPU, RAM , ROM, I/O, HD
  • flash drive
  • megahertz
  • millisecond, micro, nano, pico
  • gui, syntax, semantics, logic

.. How are things represented inside a computer?

  • There are 10 kinds of people in the world: those that understand binary and those that do not...

  • What is a byte? bit? megabyte?


  • What is a positional numbering system? Ever use one?


  • What is binary and ... WHY did they do this to us??

  • The following table shows how you can express the same abstract concept, a number, in base 2 and in base 10. (See reference)

  • BINARY (base 2) DECIMAL (base 10)
    0 0
    1 1
    10 (2^1) 2
    11 3
    100 (2^2) 4
    101 5
    110 6
    111 7
    1000 (2^3) 8
    1001 9
    1010 10 (10^1)
    1011 11
    1100 12
    1101 13
    1110 14
    1111 15
    10000 (2^4) 16
    . . . . . .
    11111 31
    100000 (2^5) 32
    . . . . . .
    111111 63
    1000000 (2^6) 64
    BINARY DECIMAL
    NOTE:
    Powers of 2 are: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, (x2)...
    Powers of 10 are: 10, 100, 1000, 10000, (x10)...

  • Unsigned binary: Number 3 is encoded as ?
  • Signed binary: Encodes negative numbers
  • Floating Point: sign, power, mantissa
  • ASCII (See reference)


  • "A" is encoded as 1000001 (66th character)
  • The character "3" is encoded as 0011 0011
  • Unicode (65536 characters) - 2 bytes per char

  • Instruction Codes


  • The BIG QUESTION: What is the ONLY language a computer understands?

  • The BIGGER QUESTION: How do we tell what ANYTHING is?? It's all just 1's and 0's!


  • What is THIS? Shorthand?

  • 4 binary digits = ??

  •       0000 : 0    1000 : 8
          0001 : 1    1001 : 9
          0010 : 2    1010 : A
          0011 : 3    1011 : B
          0100 : 4    1100 : C
          0101 : 5    1101 : D
          0110 : 6    1110 : E
          0111 : 7    1111 : F
           

  • The following table shows how you can express the same abstract concept, a number, in three different bases: base 2, base 10 and base 16 (a shorthand for base 2 numbers).

  • BINARY (base 2) HEX (base 16) DECIMAL (base 10)
    000
    111
    10 (2^1)22
    1133
    100 (2^2)44
    10155
    110 6 6
    111 7 7
    1000 (2^3) 8 8
    1001 9 9
    1010 A 10 (10^1)
    1011 B 11
    1100 C 12
    1101 D 13
    1110 E 14
    1111 F 15
    10000 (2^4) 10 (16^1) 16
    . . . . . . . . .
    11111 1F 31
    100000 (2^5) 20 32
    . . . . . . . . .
    111111 3F 63
    1000000 (2^6) 40 64
    BINARY HEX DECIMAL
    NOTE:
    Powers of 2 are: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, ...
    Powers of 16 are: 16, 256, 4096, 65536, ...
    Powers of 10 are: 10, 100, 1000, 10000, ...


    There are lots of other "numbers" used in the field of computer science


  • What do we call these small numbers? What are they?
  • (.001 = 1 ms) 10-3
  • (.000 001 = 1 us)10-6
  • (.000 000 001 = 1 ns)10-9
  • (.000 000 000 001 = 1 ps)10-12

  • What do we call these large #s? (See reference) (210 = KB, 220 = MB, 230 = GB)
  • Name
    Abbr.
    Size
    Kilo
    K
    2^10 = 1,024
    Mega
    M
    2^20 = 1,048,576
    Giga
    G
    2^30 = 1,073,741,824
    Tera
    T
    2^40 = 1,099,511,627,776
    Peta
    P
    2^50 = 1,125,899,906,842,624
    Exa
    E
    2^60 = 1,152,921,504,606,846,976
    Zetta
    Z
    2^70 = 1,180,591,620,717,411,303,424
    Yotta
    Y
    2^80 = 1,208,925,819,614,629,174,706,176

    From www.howstuffworks.com

  • If we can represent numbers in binary, can we add? (sub multiply divide)

    How?

    Math is an important part of Computer Science!!


.. How do we convert between the three bases (10, 2, 16)?

  • Binary to decimal? Add place values... (32, 16, 8, 4, 2, 1)


  • Binary to hex? Group....

    Hex to binary? Ungroup...

    Hex to decimal? Add place values... (4096, 256, 16, 1)

    Decimal to Binary? intuition OR divide by 2 and concatenate remainder digits


    Decimal to Hex? intuition OR divide by 16 and concatenate remainder digits.

.. How do we represent negative numbers?


  • What is the scheme?
  • What's the range?
  • What is meant by "taking the "twos complement"?
  • What is meant by a "twos complement" number? (DIFFERENT!!)

  •    Why does
          0000 1010b = 10?
          1111 0110b = NEG(10) = -10
          Place values change in 2's comp
           128  64  32  16  8  4  2  1 = unsigned
          -128  64  32  16  8  4  2  1 = 2's complement
          Better than sign mag or 1's comp
          Experiment with 4 bit scheme
       

.. Architecture Review

Boolean logic
Gates
Half adder
Full adder
Multiplexor
ALU - 1 bit - parallel computations
ALU multi-bit
OPcode = instruction -> drives the selectors and control
Full H&P CPU diagram
=======================

Architecture Slides (pdf)

.. How do programs run?


          
     How is Software Executed?
     =========================
    1. User enters a command to the ______ to run the program
    2. OS (loader) retrieves program from ______ and store into _______
    3. Address of first instruction to be executed is put into the _______ .
    4. Instruction is fetched from RAM and placed into the  ________.
       Update the IP
    6. Instruction in IR is decoded
       Fetch operands as needed
    7. Instruction is executed
       Store result as needed
       Set status flags
    8. Go to 4 if not done
    9. When done, control is given back to the _____
    
    
    fetch - decode - execute cycle happens HOW fast???

.. How fast do things happen in a computer?

How do we measure time?

CLOCK Hertz? = 1 clock tick per second Megahertz = 1 million ticks per sec (each tick = 1 microsecond) Gigahertz = 1 billion ticks per sec (each tick = 1 nanosecond)Clock cycle
Time can be expressed as a series of clock ticks a clock is the sequencing, stepping mechanism which is the smallest unit in which a hardware event can take place each tick of the clock is called a CLOCK CYCLE or period a cycle is measured as some fraction of a second (1 us or 100 ns)
CLOCK RATE measures how many times a clock ticks per second a clock cycle is measured as the inverse of the clock rate 1 hz is a single sine wave taking 1 second if cycle = 1 second, rate = 1 hz
Speed milli = 1 / 1000 = .001 micro = 1 / millionth = .000 001 nano = 1 / billionth = .000 000 001 pico = 1 / trillionth = .000 000 000 001
A 100 hz clock is 100 waves in a single second with each cycle taking .01 sec . So, cycle=.01, rate = 100 hz A 1 megahertz (1 mhz) clock ticks a million times per second 1 million hz is a million waves in a sec each taking .000001 or 1 microsecond
.000 000 000 000 milli micro nano pico A 1 mhz clock has a 1/1million cycle = .000 001 A 10 mhz clock has a 1/10million cycle = .000 000 100 A 100 mhz clock has a 1/100million cycle = .000 000 010
Why slow clocks? Grace Hopper's nanosecond?

.. Microcontrollers: Computers without an Op Sys

Parallax: Basic Stamp web site

=====================
Board of Education (BOE)
Basic Stamp
Pic Microcontroller
OS??
=====================

Basic Stamp Slides (pdf)