Title: Program structure and computer architecture
1Program structure and computer architecture
Jan. 10
2Hackers Tip of the Day Moores Law
3Cost of RAM
4Cost of Hard Drive Space
5(No Transcript)
6QUIZ!
- 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?
7Answers
- 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
830-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?
9News
- 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
10Computer Architecture
11Input/Output Devices
12I/O Devices
13Long Term Storage
14Long 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 )?
15Short Term Storage Working Memory (RAM)?
16Working 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)?
17CPU Central Processing Unit
18CPU 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
19CPU 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
20CPU 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
21Buses
22Buses
- Connect different parts of the computer together
- Allow communication between devices
- The faster the bus, the faster information can be
sent along
23Storage 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.
24Storage 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
25Storage Sizes Kilobyte
- 1 KB 1024 bytes
- Kilo is from latin meaning one thousand
- A paragraph or two of plain text
- A very simple webpage
26Storage 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
27Storage 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
28Storage Sizes Terabyte
- 1 TB 1024 GB
- 200,000 MP3s (more songs than youve ever heard)?
- 100 full length DVD quality movies
29Storage Sizes Petabyte
- 1 PB 1024 TB
- Entire Library of Congress is estimated at about
3 PB
30Storage Sizes Exabyte
- 1 EB 1024 PB
- Every word ever written, spoken
- Every picture ever taken
- Every sound recording
- Every video ever shot
31Storage Sizes Zettabyte
- 1 ZB 1024 EB
- Every inch of the earths surface to be monitored
with HD video for all human existence
32Program Structure
33Source Code (hello.c)?
- include ltstdio.hgt
- int main( int argc, char argv )?
-
- printf( "Hello, World!\n" )
- return( 0 )
34Include a library for printing to the screen
- include ltstdio.hgt
- int main( int argc, char argv )?
-
- printf( "Hello, World!\n" )
- return( 0 )
35stdio 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 )
36main function program always starts here
- include ltstdio.hgt
- int main( int argc, char argv )?
-
- printf( "Hello, World!\n" )
- return( 0 )
37input 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 )
38Opening curly braces beginning of a block of
code
- include ltstdio.hgt
- int main( int argc, char argv )?
-
- printf( "Hello, World!\n" )
- return( 0 )
39Opening 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
41Semicolon 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
46printf Function Displaying Text on the Screen
- printf( "Hello, World!\n" )
47printf Name of function
- printf( "Hello, World!\n" )
48Quoted 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" )
50Oops, forgot the new line character
- printf( "Hello, World!" )
- printf( "How are you?" )
51d Special marker to substitute in a variable
value into the printout
- int x 50
- printf( "The value is d\n", x )
52The name of the variable to be substituted into
the d
- int x 50
- printf( "The value is d\n", x )
53Operations with Variables
- Symbols for different mathematical operators
- for addition
- - for subtraction
- for multiplication
- / for division
54include 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
55include 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
56include 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