Day 3
I. Last Time
   A. Hw #1 Due Thurs.
   B. Movie - Early CS history and People:
Turing
von Neumann
II. New Stuff
    A. Modern Machines: 
CPU - Central Processing Unit:
The CPU does the real "work" of the computer.
It processes the data.
Basically it does 3 types of things:
Data Movement (Move data from one place to another)
Data Manipulation (Add, Mult, And, etc.)
Decision Making (Branching) (Ifs, whiles, etc.)

The Book further breaks the CPU into:
           Datapath: "Roads" for data to travel on 
               Consist of "registers" and ALU
Register is a basic unit of storage/work for a processor.
I.e. the fundamental amount of data a processors was designed for.
               ALU - Performs basic logic/arithmatic of computer
(I.e. where all data manipulation is done)

           Control: Traffic Director 
               Controls what operations are performed on data
               controls flow of program (Branching/Decisions)
           (Exception Handler)
                     
        We'll come back to this model often.

Talking to the Computer:
        Input: Mouse, Keyboard 
         Output: Monitor, Printer, Blinky Lights 
         (I/O: Network, Modem, etc.) 
         Memory/Storage: 
           Random Access: "RAM" & "Cache" - Temporary "Volatile" storage 
                          Fast/Memory Hierarchy 
           Non-Random Access (Sequential): Disks, HDs, CDs, Tapes 
                          - Non-Volatile Storage Slow/Mechanical 
For most computers, memory is a special type of storage and
Disks are just another IO device.

RAM holds instructions and data. (Thanks Von Neumann!!)
Instruction: A command for the processor to follow.
Data: A piece of information or variable.
(Actually, we're talking about a location to store
a specific piece of information here)

       Random vs. Sequential Access: When we talk about access, we're
       really talking about access TIME. I.e. how long will it take 
       to get a particular piece of information.
       Random Access - No mater what piece of information we ask for, 
                       it'll always take the same time to retrieve.
                       (We can pick randomly)
                       (Hypothetical library)
       Sequential - The information is in some order and getting 
                    one element you must go through some others.
                    (VCR tape) 
                    Some pieces of information are more readily
                    and accessable faster.                  

        In the 2nd part of the semester we'll take a look at
        this model to try to understand assemble language.
        (We'll also re-fine our picture of the datapath)

        In the last 3rd of the semester we'll figure out how 
        Memory, and the Datapath work and gain some insights 
        into the Control.
        
    
    B. Software Hierarchy & Components 
       1. OS (System Software): Manage Computers Resources 
          a. Hardware interface/communications (Think device drivers) 
             As time has progressed, these interfaces have gotten 
             quite general 
          b. Starting Applications (Loading them)
          c. Task Switching 
d. Memory Management (this is the same as a)

          REALLY - what the OS does is provide two things:
             1) Common Access to Devices
                A program needs to write to disk, it asks the OS.
                OS is responsible for understanding how to talk to disk,
                printer, display, etc. 
             2) Resource Sharing 
                The OS figures out how to share the resources available
                to the CPU: Memory & Time
             
       2. One Possible Hierarchy: 
          a. Hardware (Bare Metal) 
          b. OS (System Software) 
          c. User Applications 
          This is the layered approach of how the OS interacts with 
          the real machine - again, this is a concept we'll come back
          to later in the semester.

       3. Hierarchy of APPLICATIONS used by Programmers: 
          a. Compiler 
            Take a High Level Language (HLL) and convert it into 
            the assemble language instructions that the machine 
            actually understands. (Starts with "source code")
Breaks it into smaller pieces - nearly native to the processor.

            Assembly Language: A symbolic (mnemonic) based 
                representation of the actual instructions the computer 
                understands. 
                The "BASE" (lowest/simplest) Language of the computer. 
                Like any other language there are rules of syntax. 
                EX: a=b+c  <-> ADD $1,$2,$3 
                We'll spend the 2nd part of the semester learning ASM
                (The programs still "readable" at this point, but may not
                 be easily understandable)

          b. Assembler 
                Converts the symbolic representation (Assembly Language) 
                into the 1s and 0s that the CPU actually reads (Machine 
                Language). 
                Fills in/creates some details (Calculates some addresses, 
                    determines constants, etc.) 
             The Assembler ususally produces an OBJECT file as output. 
             (We'll be playing the part of the assembler soon - 
              learning how to take an instruction and convert it into 
              the binary that the CPU reads)

          c. Linker: 
                The sticky tape that binds the whole mess toghether. 
                The Linker "links" together seperate object files and 
                fills in all the final details. It produces a file in 
                a format which the operating system is capable of 
                "loading" and which should be capable of executing. 
                (Consolidates "globals", allows seperate compilation 
                 of components) 

         Source File -> (Compiler) -> ASM File (ASM Lang) -> (Assembler) -> 
         Object File (Machine Lang) -> (Linker) -> Executable -> (Loader (OS)) -> 
         Running Program


    C. All you want to know about assembly 
       Why know/understand ASM: 
         1. Can be smaller / Faster 
         2. Sometimes nesc. to work with hardware 
         3. Can sometimes better utilize Processors by using an 
            instruction which the compiler would not. 
         4. On Some Processors, a compiler isn't available yet. (New design) 
         5. Sometimes need to be able to read to debug a program 
         6. ""       "" to estimate run time of a program 
       The Downside: 
         1. Not very portable (and often "advantages" are lost if a 
            little portable) 
         2. Expansion: 1 inst in C is often 5+ insts in asm 
         3. Tedious/Complex.: Often only 8-20 variables to use. 
(In our case, bad variable names, shared variables)
         4. VERY difficult to read/understand 

     D. Misc:
         Linking is the process of "sewing" the various pieces of a 
         program together: 
            Statically linked: Except for the OS the program is self 
                               contained. I.e. All subroutines/etc. are in 
                               one file (except system calls - I.e. OS stuff) 

            Dynamically linked: Some functions/subroutines/components are in 
                                another file which needs to be present to run
                                the program. Ex. Window's DLLs This saves 
                                overall space because there is just a single 
                                copy of the commonly used subroutines on disk.
                                (Instead of a copy in every program that uses it)
            Profiler: "Profiles" execution of code. Gives actual "timing"
                       data of how long parts of the code take to execute 
            
            Loader: A component of the OS which actually "loads" a file to 
                    be run. (The file must be in the proper format for the 
                    loader to interpret) 
                    A loader is often responsible for verifying that the 
                    "dynamic" parts of a program are present and "linking" 
                    to them. 
                    (Ever seen the windows "Missing DLL" Window? 
                     That's because a program was dynamically linked 
                     and the loader failed to locate something that it 
                     needed)
III. Next Time
     A. Performance!
     B. Hw #1 Due Thurs, Hw #2 posted Thurs