Program structure and computer architecture - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

Program structure and computer architecture

Description:

What is the name of the compiler that we will be using ... DVD-drive physically whirs up DVDs to 52X speed. Flash drives are the exception (no moving parts) ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 57
Provided by: iuinfor
Category:

less

Transcript and Presenter's Notes

Title: Program structure and computer architecture


1
Program structure and computer architecture
Jan. 10
2
Hackers Tip of the Day Moores Law
3
Cost of RAM
4
Cost of Hard Drive Space
5
(No Transcript)
6
QUIZ!
  • In your own words, describe in one sentence what
    a compiler does
  • What is the name of the compiler that we will be
    using this semester?
  • Suppose we just wrote a program and saved it in a
    file called hello.c. What command would you use
    to compile it?
  • What command would you use to create a new
    integer variable called movieCount that has a
    value of 107?

7
Answers
  • A compiler converts a plain text file containing
    a computer program into an executable file that
    the computer can run.
  • gcc
  • gcc Wall o hello.exe hello.c
  • int movieCount 107

8
30-Second Survey
  • Attempted to get Cygwin/Mac Developer tools
    installed?
  • Succeeded?
  • Got emails sent to class email list?
  • Know how to convert between decimal and binary
    numbers?

9
News
  • Textbook wont be available from the bookstore
    for a while.
  • Recommendation get it from Amazon (its cheaper
    there anyway)?
  • Windows Vista users
  • New tutorial about getting Linux working on Vista
  • Link available from the course webpage
  • Good text editor for Windows
  • Notepad

10
Computer Architecture
11
Input/Output Devices
12
I/O Devices
13
Long Term Storage
14
Long Term Storage
  • Data remains intact when computer is shut off
  • Relative Access speed Slow
  • Access requires physical movement
  • Hard drive disk has to physically spin to
    read/write data
  • DVD-drive physically whirs up DVDs to 52X speed
  • Flash drives are the exception (no moving parts)?
  • Relative Cost Per Byte Low
  • 500 GB harddrive 75 ( about 7 GB per
    dollar )?
  • 500 DVD-R 100 ( over 2 TB )?

15
Short Term Storage Working Memory (RAM)?
16
Working Memory/RAM
  • Volatile data is lost when computer is shut off
  • Relative Access Speed Medium
  • No moving parts like some persistent storage
    mechanisms
  • Relative Cost Per Byte Medium
  • 4 GB of DDR2-667 300 ( 14 MB per
    dollar)?

17
CPU Central Processing Unit
18
CPU Central Processing Unit
  • Performs all actual calculations
  • Has a relatively small set of low-level
    instructions
  • Add two numbers
  • Multiply two numbers
  • Load a number from memory
  • Store a result into memory
  • Jump to a different instruction to execute

19
CPU Cache (L1, L2, L3 cache)?
  • Small amount of working memory built right onto
    the CPU (sometimes called onboard cache)?
  • Relative Access Speed Fast
  • Close proximity to CPU leads to very little delay
    to store and load data
  • Relative Cost Per Byte High
  • A modern computer might have a 1 MB L2 CPU cache

20
CPU Registers
  • Tiny amount of memory built directly into the CPU
  • Registers typically store only the data that is
    being used for the single operation that the CPU
    is currently working on
  • Relative Access Speed Ultra Fast
  • Relative Cost Per Byte Ultra High
  • Several hundred bytes per CPU

21
Buses
22
Buses
  • Connect different parts of the computer together
  • Allow communication between devices
  • The faster the bus, the faster information can be
    sent along

23
Storage Sizes Bit
  • Store only 1 of two values
  • 0 or 1
  • Off or On
  • False or True
  • You can store the answer to any yes/no question.
    But thats it.

24
Storage Sizes Byte
  • 1 byte 8 bits
  • Store values from 0 to 255 (hint 28 256)?
  • Store any single keyboard character
  • 00000000 a
  • 00000001 b
  • 00000010 c
  • 00000011 d

25
Storage Sizes Kilobyte
  • 1 KB 1024 bytes
  • Kilo is from latin meaning one thousand
  • A paragraph or two of plain text
  • A very simple webpage

26
Storage Sizes Megabyte
  • 1 MB 1024 KB
  • One rather high quality digital photograph
  • 1 minute of high quality MP3 (music quality)?
  • 5 minutes of low quality MP3 (spoken word
    quality)?
  • Several hundred pages of text

27
Storage Sizes Gigabyte
  • 1 GB 1024 MB
  • Are you noticing a pattern?
  • 3000 nice quality digital photographs
  • 200 high quality music MP3s
  • 5 minutes of high quality digital video

28
Storage Sizes Terabyte
  • 1 TB 1024 GB
  • 200,000 MP3s (more songs than youve ever heard)?
  • 100 full length DVD quality movies

29
Storage Sizes Petabyte
  • 1 PB 1024 TB
  • Entire Library of Congress is estimated at about
    3 PB

30
Storage Sizes Exabyte
  • 1 EB 1024 PB
  • Every word ever written, spoken
  • Every picture ever taken
  • Every sound recording
  • Every video ever shot

31
Storage Sizes Zettabyte
  • 1 ZB 1024 EB
  • Every inch of the earths surface to be monitored
    with HD video for all human existence

32
Program Structure
33
Source Code (hello.c)?
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

34
Include a library for printing to the screen
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

35
stdio stands for standard input/output
Include a library for printing to the screen
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

36
main function program always starts here
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

37
input into the main function don't worry...just
copy/paste
main function program always starts here
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

38
Opening curly braces beginning of a block of
code
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

39
Opening curly braces beginning of a block of
code
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

Closing curly braces end of main function block
of code
40
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

Statements inside of braces instructions for
program
41
Semicolon is required at the end of each
instruction
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

42
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • printf( "I already said hi!\n" )
  • return( 0 )

Statements execute in sequential order
43
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Value is d\n", x )
  • int x 10
  • return( 0 )

Statements execute in sequential order
44
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Value is d\n", x )
  • int x 10
  • return( 0 )

Statements execute in sequential order
45
  • include ltstdio.hgt
  • int main( int argc, char argv )?
  • printf( "Hello, World!\n" )
  • return( 0 )

Return goes at end of main function copy/paste
for now
46
printf Function Displaying Text on the Screen
  • printf( "Hello, World!\n" )

47
printf Name of function
  • printf( "Hello, World!\n" )

48
Quoted text (with double quotes) to be printed out
  • printf( "Hello, World!\n" )

49
\n Special character that prints out a new line
(like pressing enter)?
  • printf( "Hello, World!\n" )

50
Oops, forgot the new line character
  • printf( "Hello, World!" )
  • printf( "How are you?" )

51
d Special marker to substitute in a variable
value into the printout
  • int x 50
  • printf( "The value is d\n", x )

52
The name of the variable to be substituted into
the d
  • int x 50
  • printf( "The value is d\n", x )

53
Operations with Variables
  • Symbols for different mathematical operators
  • for addition
  • - for subtraction
  • for multiplication
  • / for division

54
include ltstdio.hgt int main( int argc, char
argv )? int x 3 int y 0 y x 2
printf( The value of y is d\n, y ) return(
0 )
x and y Two different variables
55
include ltstdio.hgt int main( int argc, char
argv )? int x 3 int y 0 y x 2
printf( The value of y is d\n, y ) return(
0 )
Assign y a new value
56
include ltstdio.hgt int main( int argc, char
argv )? int x 3 int y 0 y x 2
printf( The value of y is d\n, y ) return(
0 )
Print out new value of y
Write a Comment
User Comments (0)
About PowerShow.com