BIM111 Introduction to Computer Engineering - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

BIM111 Introduction to Computer Engineering

Description:

High level languages, Compiler, Assembler, Linker, Loader and Operating system ... following a recipe or assembling a bookcase, the algorithm tells us each step in ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 30
Provided by: cengAna
Category:

less

Transcript and Presenter's Notes

Title: BIM111 Introduction to Computer Engineering


1
BIM111 Introduction to Computer Engineering
  • Software

2
Contents
  • Software, Program, Algorithm
  • Basic Operation of the Computer
  • System Software Components
  • High level languages, Compiler, Assembler,
    Linker, Loader and Operating system
  • Software Development Cycle

3
Program (Software)
  • Conceptually a program is a step-by-step solution
    to a problem
  • Also named an algorithm
  • A well-defined computational procedure that takes
    some values (data) as input and produces some
    results as output

4
Example Program Compute the sum, product and avg
of 2 numbers, a b
DATA
ALGORITHM
a ? 10 b ? 40 sum ? ab product ? ab avg ?
sum/2 print sum print product print avg
a
10
?
?
b
?
40
sum
?
50
product
?
400
avg
25
?
SCREEN
50 400 25
5
Basic Operation of the Computer
  • loop
  • Fetch the next instruction from memory
  • Decode the instruction
  • Interpret what the instruction means
  • Fetch the operands (if necessary)
  • Fetch the operands from memory to CPU registers
  • Execute the instruction
  • Perform what the instruction is telling us to do
    (add, subtract, multiply, divide, )
  • Store the result back to memory (if necessary)
  • repeat

6
Example Program Execution
MEMORY
S1 a ? 10 S2 b ? 40 S3 sum ? a b S4 product
? ab S5 avg ? sum/2 S6 print sum S7 print
product S8 print avg
Instructions
CPU
Registers
IP
ALU/ FPU
10
10
50
SCREEN
a
10
?
S2
S4
S5
S6
S7
S8
S1
S3
40
40
25
50 400 25
b
Control Unit
40
?
50
400
sum
?
50
DATA
product
?
400
avg
?
25
7
From Algorithm to 0s and 1s
  • Although we showed the instructions stored in
    memory in pseudo-code (human readable form), what
    is really stored is 0s and 1s
  • Remember a computer only understands 0s and 1s
  • This means that we need tools that would help us
    convert the program from human-readable form to
    the machine-readable form called the machine
    language
  • These tools are called system software tools

8
System Software Components
  • We have several system software components to
    make programming the computer easy
  • High-level Programming Languages (C, C, Java,
    C, ..)
  • Compiler
  • Converts your programs implemented in high-level
    language to assembly language, which are mnemonic
    codes that correspond one-to-one with machine
    language
  • Assembler
  • Converts programs implemented in assembly
    language to machine language, which are binary
    number codes understood by a specific CPU
  • Linker
  • Combines several object files together into an
    executable
  • Loader Operating System
  • Loads your program into memory for execution
  • Relevant Course BIM201 System Software

9
Operating System
  • Is a layer of software that exports an
    easy-to-use interface to program the hardware

User Programs
P1
P2
Pn
System call API
Operating System (Windows, Linux, Solaris, )
Hardware API
Hardware
  • User programs make use of the hardware through
    the services provided by the OS
  • Thus OS makes life easier for user programs
  • Relevant course BIM322 Operating Systems

10
Problem Solving
  • Computer programs are written to solve problems.
  • Coding a computer program should not be started
    until all plans are made.
  • First, a solution is created, and then the
    program is coded in a computer language.
  • The key is planning.

11
Software Development Cycle
  • 1. Specify problem requirements
  • State the problem clearly understand what is
    required
  • 2. Analyze the problem
  • Identify the inputs (data), outputs (results),
    and any additional requirements
  • 3. Design a solution (algorithm)
  • Develop the list of steps that solves the problem
  • Do Procedural Design or Object-Oriented Design
  • 4. Implement the algorithm
  • Code the algorithm using a programming language
    (C, C, Java, C, )
  • Notice that an algorithm is independent of the PL

12
Software Development Cycle (cont)
  • 5. Test and verify
  • Run the code with many sets of test data to
    verify that it does what it is supposed to do
  • 6. Maintain and update code
  • Modify the code as needed
  • Relevant Courses
  • Introduction to Computer Engineering
  • C Programming
  • Visual Programming
  • Object Oriented Programming
  • Advanced Programming Techniques
  • System Analysis Design
  • Software Engineering
  • Programming Language Concepts

13
Algorithms
  • We use algorithms every day.
  • Whenever we are doing a task, such as following a
    recipe or assembling a bookcase, the algorithm
    tells us each step in the proper order.

14
Ex-ATM Machine
  • Problem Design an algorithm for a simple ATM
    machine
  • Get the password from the user
  • If the password is not valid, construct an error
    message and skip to step 6.
  • Get the inputs
  • 3.1 Get the transaction type (deposit or
    withdrawal), and the amount from the user.
  • 3.1 Get the current balance from the bank.
  • (continued on next page)

15
Ex-ATM Machine (cont)
  • If the transaction type is deposit, add the
    amount to the current balance.
  • If the transaction type is withdrawal, check the
    current balance
  • 5.1 If amount is greater than the current
    balance, construct an error message and skip to
    step 6.
  • 5.2 If amount is equal to or less than the
    current balance, subtract the amount from the
    current balance.
  • Output the error message or the cash, and the
    current balance.
  • Ask the user whether to repeat steps 3 through 6
    for another transaction.

16
Ex1-Making a Sandwich
  • Problem Design an algorithm to make peanut
    butter and jelly sandwich
  • Inputs
  • Bread (at least 2 slices)
  • Peanut Butter
  • Jelly
  • Knife
  • Plate to place the sandwich on
  • Output
  • One sandwich

17
Ex1-Making a Sandwich (cont)
  • Put the bread, peanut butter, jelly, knife and
    plate onto the workplace
  • Place two slices of bread on the plate
  • Using knife spread the peanut butter on one slice
  • Spread jelly on the other slice using the knife
  • Slap the two pieces together, sticky side in
  • Eat the sandwich

18
Ex1-Making a Sandwich (cont)
  • Step 1 is the input
  • Steps 2-5 explain the process
  • Step 6 is the output
  • Clearly, we must do steps one after the other
  • We should not do step 5 before step 3 or the
    sandwich would not be very interesting

19
Ex2-Convert Fahrenheit-to-Celsius
  • Problem Design an algorithm to convert a
    fahrenheit temperature to celsius temperature
  • Input
  • Temperature in fahrenheit degrees
  • Output
  • Temperature in celsius degrees

20
Ex2-Convert Fahrenheit-to-Celsius
  • Prompt the user and get the fahrenheit
    temperature to convert
  • celsius (fahrenheit-32)/1.8
  • Print the fahrenheit and celsius degrees on the
    screen

21
Ex3-Compute the sum, product and average of 2
numbers
  • Problem Design an algorithm to find the sum,
    product and average of 2 numbers
  • Input
  • 2 numbers
  • Output
  • Sum, product and average of the numbers

sum
num1
program
prod
num2
avg
22
Ex3-Compute the sum, product and average of 2
numbers
  • Prompt the user and get number1 and number2
  • sum number1 number2
  • product number1 number2
  • average sum / 2
  • Print sum, product, average

23
Ex4-Compute the circumference and the area of a
circle
  • Problem Design an algorithm to compute the
    circumference and the area of a circle
  • Input
  • The radius of the circle
  • Output
  • The circumference and the area of the circle

24
Ex4-Compute the circumference and the area of a
circle
  • Prompt the user and get the radius of the circle
  • circumference 2 3.14 radius
  • area 3.14 radius radius
  • Print the circumference and the area

25
Ex5-Compute the minimum and maximum of 2 numbers
  • Problem Design an algorithm to find the minimum
    and maximum of 2 numbers
  • Input
  • 2 numbers
  • Output
  • Minimum and maximum of the numbers

26
Ex5-Compute the minimum and maximum of 2 numbers
  • Prompt the user and get number1 and number2
  • if (number1 lt number2)
  • 2.1. min number1
  • 2.2. max number2
  • else (i.e., number1 gt number2)
  • 3.1. min number2
  • 3.2. max number1
  • Print min and max

27
Ex6-Compute the minimum of 3 numbers
  • Problem Design an algorithm to find the minimum
    of 3 numbers
  • Input
  • 3 numbers
  • Output
  • Minimum of the numbers

28
Ex6-Compute the minimum of 3 numbers
  • Prompt the user and get number1, number2 and
    number3
  • if (number1 lt number2)
  • 2.1. if (number1 lt number3) then min number1
  • 2.2. else (i.e., number3 lt number1) min
    number3
  • else (i.e., number1 gt number2)
  • 3.1. if (number2 lt number3) min number2
  • 3.2. else (i.e., number3 lt number2) min
    number3
  • Print min

29
Ex7-Compute the minimum of 3 numbers (2nd
Algorithm)
  • Prompt the user and get number1, number2 and
    number3
  • min number1 (Assume that number1 is min)
  • if (number2 lt min) min number2
  • if (number3 lt min) min number3
  • Print min
Write a Comment
User Comments (0)
About PowerShow.com