5 basic components of any computer - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

5 basic components of any computer

Description:

Gets data from main memory (primary storage) Operates on at most 2 pieces of data ... Kilobyte (K) = ~ 1000 bytes (210) Megabyte (M) = ~ 1,000,000 bytes (220) ... – PowerPoint PPT presentation

Number of Views:251
Avg rating:3.0/5.0
Slides: 20
Provided by: suzannew6
Category:

less

Transcript and Presenter's Notes

Title: 5 basic components of any computer


1
5 basic components of any computer and how they
interact
CPU
Output Devices
Main Memory
Input Devices
Secondary Memory
2
  • CPU (Central Processing Unit)
  • Performs program control
  • Gets data from main memory (primary storage)
  • Operates on at most 2 pieces of data at a time
  • Performs calculations
  • Arithmetic (, -, , / )
  • Logic (lt, lt, gt, gt, !, )
  • Boolean result true or false

3
  • Memory
  • Ordered sequence of storage locations (cells)
  • each location has an address
  • RAM random access memory (read/write)
  • ROM read-only memory
  • composed of bits (binary digits a 0 or 1)
  • byte 8 bits
  • nibble ½ byte 4 bits
  • each cell is some number of bytes depending on
  • the computer

4
1 bit can represent 2 things (0 or 1) gt 21 How
many different things can x bits represent? 22
? 23 ? 24 ? 25 ? 26 ? 27 ? 28
? Kilobyte (K) 1000 bytes (210) Megabyte (M)
1,000,000 bytes (220) Gigabyte (G)
1,000,000,000 bytes (230)
5
  • Main Memory
  • ROM and RAM
  • volatile (needs power)
  • closest memory to CPU
  • limited amount available
  • often multi-layers
  • Secondary Memory
  • RAM
  • non-volatile (doesnt need power)
  • farther from CPU (longer time to access)
  • unlimited storage

6
Various Kinds of Input Devices? Various
Kinds of Output Devices?
7
  • Weve looked at a computers structure,
  • now look at software and languages
  • -- A computer program is a sequence of steps
    (statements) that are instructions to the
    computer for solving a problem.
  • Questions
  • What kinds of software are there?
  • What language do we use to write programs?
  • What kinds of languages are there?
  • What language(s) does a computer understand?
  • How does all this work??

8
Operating Systems (OS)
  • An OS is software a computer program
  • Provides interface between current program and
    hardware
  • Controls peripheral devices such as fetching data
    from memory, sending data to printers, etc.
  • Schedules program execution, multitasking
  • Sets up memory space for running program
  • Protects underlying system from a users program

9
Operating Systems contd
  • OS is started when computer is turned on it
    boots the computer (from bootstrapping)
  • Examples
  • Microsoft Windows
  • MacOS
  • Unix
  • Linux

10
  • Computers understand low-level languages
  • machine language is in bits
  • for example 11100000 10101010
  • might mean place value 10 in cell 20
  • assembly language is mnemonic codes
  • LOAD R1, 40
  • LOAD R2, 20
  • ADD R1, R2
  • STORE R1, 320X
  • Not very convenient for us!

11
Humans prefer high-level languages that are
easier for to read and write (more
like English) For example int x // x is a
memory location int y // so is y int
result // and also result x 40 // put
value 40 in x y 20 // put value 20 in y result
x y // put value of x y in result
12
What are examples of high-level languages? Java,
??
13
Our problem? Computers only understand
low-level language programs need some way
to convert our high-level language programs
to low-level language programs Answer? A
Compiler is software (a program) that takes as
input a high-level language program and converts
it to a functionally equivalent program in a
lower-level language
PHL
PLL
Compiler
14
To compile a Java program
Java byte code
Java source code
Java Compiler
Then to execute (run) the program
Java byte code
Java Interpreter
Program output
Java library routines
15
  • Creating a program
  • using TextPad, type in your program code
  • need to name the file that stores the program
  • file name is the same (exactly) as the program
  • class name plus .java
  • ex
  • public class HelloWorld
  • .
  • ? file is named HelloWorld.java
  • after compiling HelloWorld.java we get
  • HelloWorld.class which is executable and
  • ready to be run

16
/ traditional first program / public class
HelloWorld // every program must have a
"main" method public static void main( String
args ) // Print a
message to the screen
System.out.println("Hello World!!")
// end of main method // end of program
HelloWorld
17
  • Errors you can make when typing in programs
  • missing semicolons ()
  • most lines end with a
  • mis-spelled words
  • Int instead of int
  • system.out instead of System.out
  • Main instead of main
  • be careful! Java is case-sensitive
  • unmatched curly braces
  • every needs a matching

18
Types of Program Errors
  • Compile-time errors syntax errors detected
    during the compilation phase results in an
    error message
  • Run-time errors cant be detected at
    compile-time, for example
  • divide by zero possible here result 20 / x
  • Logic errors our thinking or implementation was
    faulty we get an answer but know it isnt
    correct

19
Debugging getting rid of bugs
  • Compile-time errors
  • fix as many errors as you can see start at top
    of error list
  • re-compile and start again
  • some errors cascade from previous ones and go
    away once others fixed
  • Run-time errors often not difficult to fix
  • Logic errors hardest to find and fix no
    messages to identify where problem is!
Write a Comment
User Comments (0)
About PowerShow.com