CSCI 1300
Lecture Notes


10/1/97

Administrative Stuff 



Administrative Stuff

  • The conference

  • Quiz #2 - Tuesday Oct. 7
  • Programming assignment #5 due Oct. 3
  • Programming assignment #6 due Oct. 10


  • Parameter passing and arrays

    Example:
    array declaration: char name[50];

    function call: print_name(name);

    function definition: print_name(char name[]) {...}



    Storage

    Signed numbers

    Signed numbers in computer systems are generally represented with 2's complement notation.

    The leftmost bit of a 2's complement number indicates whether the number is positive (leftmost bit == 0) or negative (leftmost bit == 1).

    The 2's complement of a number is obtained by complementing the binary representation of the number and adding 1 to it.

    Example:

    109d = 01101101b

    In a 32-bit system this would be represented as:

    01111111111111111111111110010011b


    Real Numbers

    Real numbers are stored in binary format much like whole numbers.

    Example:

    24.5 = (1 * 2^4) + (1 * 2^3) + (1*2^-1)

    In memory, we store two things: The binary representation of the number (called the mantissa, and the location of the decimal point (called the exponent).

    So, the storage for 24.5 would look something like this:

    00000000000000000000011000111010
    |__________________________||____|
    -------Mantissa------- Exponent

    Note: Precision


    ASCII

    ASCII is a standard that assigns numeric codes to printable characters so we can store text in a computer.

    ASCII use 8 bits = 1 byte per character.

    1 Borland C++ word = 4 bytes => each word can hold 4 characters.



    Computer Architecture

    Note: Picture


    Central Processing Unit (CPU)

  • Controls the operation of the entire system.

  • Performs arithmetic and logical operations

  • Stores and retrieves data and instructions

  • The CPU is the thing that actually executes instructions.

    A CPU has:

  • Registers
  • Program counter
  • Control unit
  • Stack pointer
  • ALU
  • Cache memory, small (usually < 1 meg) but extremely fast
  • ...


    Main memory

  • Stores instructions and data

  • Adressable

  • Much larger than cache (16-128 Meg), but slower

  • Volatile storage


    Secondary storage

  • Much larger than main memory, but much slower

  • Randomly accessable or sequential

  • Floppy disk, hard drive, CD-ROM, magnetic tape, paper tape, punchcards

  • Non-volatile storage


    Input/Output devices (I/O)

  • Transmit information to and from the computer

  • How we interact with the computer

  • Accessed through special hardware registers

  • Monitor, keyboard, mouse, joystick, light pen, printer, speakers, etc.



    Coding, Compiling, Executing

    High-level languages
  • Provide high-level abstractions for data and algorithms

  • Facilitate creation of complex programs

  • Examples: C++, Lisp, Basic, Fortran, Pascal, etc.

  • Example: x = ((x * y) + z);

  • Assembly language
  • Low-level abstractions for data and algorithms

  • Often just mnemonics for actual machine instructions

  • Close to machine representation -> efficient

  • Example:

    LOAD a,$x
    MULT a,$y
    ADD a,$z
    STORE a,$x
  • Machine instructions
  • This is the representation that the CPU understands.

  • 1's and 0's, including instruction and data

  • Opcodes and operands

  • Example:

    Data:
    4 = 100b
    5 = 101b
    6 = 110b

    Opcodes:

    LOAD = 16 = 00010000b
    STORE = 17 = 00010001b
    ADD = 35 = 00100011b
    MULTIPLY = 36 = 00100100b

    Instructions:
    0001000000000100 ----- Load the value in memory location 4 into the accumulator
    0010010000000101 ----- Multiply the value in the accumulator by the value in memory location 5
    0010001100000110 ----- Add the value in memory location 6 to the value in the accumulator
    0001000100000111 ----- Store the value in the accumulator into memory location 7

  • Executing an instruction
  • Fetch instruction

  • Fetch operands

  • Decode instruction

  • Execute operation

  • Store result


  • A Compiler

  • Converts a high-level program into a list of machine instructions

  • The list of machine instructions is called an executable file

  • All of the variable and function names are converted to addresses

    When we execute a file

  • The contents of the executable file are placed in memory

  • The operating system begins executing instructions at a pre-specified place in memory.

  • The CPU executes instructions, one after the other, until the program is finished.

    Each instruction

  • Has an opcode and zero or more operands

  • The instructions can:
  • Load values from memory into registers
  • Operate on the registers
  • Store values into memory

  • Special instructions modify PC to jump, branch, etc.