0% found this document useful (0 votes)
6 views64 pages

PF Lec 1

The document provides an overview of essential computer hardware and software components, emphasizing the roles of input, processor, memory, storage, and output devices. It discusses the relationship between hardware and software, detailing types of software including system and application software, as well as programming languages and their classifications. Additionally, it covers the processes involved in compiling and interpreting programming languages, highlighting the importance of compilers and assemblers in translating high-level code to machine language.

Uploaded by

slowmanremember
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views64 pages

PF Lec 1

The document provides an overview of essential computer hardware and software components, emphasizing the roles of input, processor, memory, storage, and output devices. It discusses the relationship between hardware and software, detailing types of software including system and application software, as well as programming languages and their classifications. Additionally, it covers the processes involved in compiling and interpreting programming languages, highlighting the importance of compilers and assemblers in translating high-level code to machine language.

Uploaded by

slowmanremember
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Lecture 1

SECTION 1

HARDWARE REVIEW
Essential components that are present
in every type of computers
At the highest level, two things
are required for computing
Hardware: The physical equipment in a
computing environment such as the
computer and its peripheral devices
(printers, speakers, etc.)

Software: The set of instructions that


operates various parts of the hardware.
Also termed as “computer program”
We’ll have a lot to say about software
during the duration of this course

However, for the First Part, let’s


concentrate on hardware
All computers have the following
essential hardware components:
Input – the component through which a user instructs a
computer about what to do
Processor – the engine that processes the instructions
given by the user
Memory – where the processor stores information that is
required during its computations
Storage – where information that is required to be used
much later is stored
Output – the component that communicates the results
of a computation to the user
There is another quite essential component
that is present in every computer …

????
The Bus!
Contro Keyboar Mou
Integer
l d se
Unit
Unit Compac
Floatin t
Cache
g Disk
Memor
Point
y
Unit
Processor
M Hard
System Bus
e Disk
m
o
r
y
B
u
Memory Printer Monitor
s
Input Devices
• Mouse
• Keyboard
• Joystick
• Camera
• Microphone
• Scanner
What’s a
Port?
Port
The connection point at which we connect
input and output devices to a computer
Many Types of Ports

1. Parallel
2. Serial
3. SCSI
4. USB
5. Firewire
Processor
• Pentium
• Celeron
• Athlon
• PowerPC
• Crusoe (Laptops)
• SPARC (Workstations)
Memory/Storage
• RAM
• Punch cards
• ROM
• Hard disk
• Floppy disk
• Tape
• CD
• DVD
Classifying Memory/Storage
• Electronic (RAM, ROM)
magnetic (HD, FD, Tape), optical (CD, DVD)

• Volatile (RAM), non-volatile (HD)

• Direct access (RAM, HD), serial access (Tape)

• Read/write (HD, RAM), read-only (CD)


Output Devices
Printer

Plotter

Speakers

Monitor
modem
input device or output device?
mo●dem
Modem is an example of a device
that acts both as an input as well
as an output device

• Can you think of any other such


dual-purpose devices?

– Network card
– Touch screens
SECTION 2

SOFTWARE REVIEW
Two things are required for
computing

Hardware: The physical equipment in a


computing environment such as the computer
and its peripheral devices (printers, speakers...)

Software: The set of instructions that operates


various parts of the hardware. Also termed as
“computer program”
Computer Software
• The HW needs SW to be useful; the SW needs
HW to be useful

• When the user needs something done by the


computer, he/she gives instructions in the form
of SW to computer HW

• These instructions need to be written in a


language that is readily understood by
computer.
Two Major Types of SW
• System SW
– Programs that generally perform the background tasks in a
computer. These programs, many times, talk directly to
the HW

• Application SW
– Programs that generally interact with the user to perform
work that is useful to the user. These programs generally
talk to the HW through the assistance of system SW

• The diagram on the screen shows the relationship


between HW and these two types of SW
Hardware
Device
Operating System Driver
Languag
Scientifi Busines Productivit Entertainme
Utilit e
c s y nt
y Translato
Apps. Apps. Apps. Apps.
r

System software

Application software
Programming
Language?
A vocabulary and set of
grammatical rules for
instructing a computer to
perform specific tasks
There are rules for both
Syntax (grammar)
and
Semantics (meaning)
Syntax
• A formal Set of Rules that defines exactly
what combinations of letters, numbers and
symbols can be used in a programming
language.
• Syntax rules are the blue prints to build
instructions in a Program, to assemble
constructs (correct structures) from the basic
building blocks
If a program violates any of the rules of the
language , it is said to have Syntax errors
Syntax Rules themselves are written in a very
simple, precise, formal language called
Meta-language. (e.g., Backus-Naur Form)
Examples of
Programming
Language?
Machine Language
Assembly Language (1956-63)
LISP (1956)
Fortran (1957) Ada(1983)
COBOL (1959) C++ (1983-85)
PL/1(1964) QBasic (1986)
BASIC (1964) Perl (1987)
Pascal (1970) VisualBasic (1991)
Smalltalk (1972) PowerBuilder
C (1972) Java (1995)
JavaScript
C# (2001)
Types of
Programming
Languages?
Computer Programming
Languages

– Low level languages / Machine language


– Assembly Language
– High level languages
Machine Languages

Any computer can directly understand only its own


machine language.

▪ It is defined by hardware design of that


computer.

▪ Machine languages generally consist of strings of


numbers (ultimately reduced to 0s and 1s)that
instruct computers to perform their most
elementary operations one at a time.

▪ Machine languages are machine dependent, i.e.


Assembly Languages

▪ Instead of using the strings of numbers,


programmers began using English like
abbreviations to represent the elementary
operations of the computer.

▪ These abbreviations form the basis of


assembly languages.

▪ Translator programs called assemblers


High-level Languages

▪ To speed the programming process,


high-level languages were developed in
which single statements accomplish
substantial tasks.

▪ Translator programs called compilers /


interpreters convert high-level language
programs into machine language.

▪ High-level languages allow programmers to


write instructions that look almost like
High-level programming languages,
while simple compared to human
languages, are more complex than the
languages the µP actually understands,
called machine languages

Each different type of microprocessors


has its own unique machine language
Lying between
machine languages
&
high-level languages
are languages called
assembly languages
Assembly languages are similar to
machine languages, but are easier to
program in as they allow a programmer to
substitute names for numbers

Machine languages consist of numbers only


Compiler
• Program that reads a program written in
one language - source language - and
translates it into an equivalent program
in another language - target language -.
Source Target
Compiler
Code Code

Err
ors
contd..
• Variety of source languages e.g. C,
Pascal.
• Variety of target languages e.g. any
other programming language, machine
language of any computer b/w a
microprocessor to a super computer.
Compiler

C++ Program C++ Machine


Language
Compiler Program
int main() {
int i=1;
. . . 01001001
10010100

Created with text editor or


development environment
An Assembler

Assembly
Language
Assemble Machine
Language
Program r Program

ST 1,[801]
01001001
. . .
10010100

Assembly & Machine Code


Assembly & Machine Language
Assembly Language Machine Language
ST 1,[801] 00100101 11010011
ST 0,[802] 00100100 11010100
TOP: BEQ [802],10,BOT 10001010 01001001 11110000
01000100 01010100
INCR [802]
01001000 10100111 10100011
MUL [801],2,[803]
11100101 10101011 00000010
ST [803],[801]
00101001
JMPTOP 11010101
BOT: LD A,[801] 11010100 10101000
CALL PRINT 10010001 01000100
Interpreter is a program that
executes instructions written in a
high-level language

An interpreter translates high-level


instructions into an intermediate form, which
it then executes

In contrast, a compiler translates high-level


instructions directly into machine language
Compiled programs generally run faster
than interpreted programs

The advantage of an interpreter, however, is


that it does not need to go through the
compilation stage during which the whole of
the high-level code is translated into machine
instructions in one go. This process can be
time-consuming if the program is long.

The interpreter can immediately execute


high-level programs, without waiting for the
completion of the translation process
Program is created in the
Editor Disk editor and stored on disk.
Preprocessor program
Preprocessor Disk processes the code.
Compiler creates object
Compiler Disk code and stores
it on disk.
Linker Disk Linker links the object
code with the libraries
Primary Memory
Loader
Loader puts program
in memory.
Disk ..
..
..

Primary Memory
CPU takes each
CPU instruction and
executes it, possibly
storing new data
..
..
values as the program
..
executes.
Language Processing System Text Editor:
• Used to write the code
Other Sources Text Editor Debugger of the program in high
& modules level language.
Skeletal Source Program
Preprocessor
• Word Processor can’t
be used because lot of
Source Program other information
Compiler including the text is
Target Assembly Program saved in the file
Assembler • Some Text Editors for
Relocatable machine code certain languages has
or Object Code special features
Linker specifically designed
Absolute Machine Code for editing source
Loader programs in that
languages
• Language Processing System Skeletal Source
Program / Code
Other Sources Text Editor Debugger • Contains that part of
& Programs
Skeletal Source Program source code (written in
Preprocessor
high level language)
which defines the basic
Source Program functionality of your
Compiler program.
Target Assembly Program

Assembler
Relocatable machine code
or Object Code
Linker

Absolute Machine Code


Loader
• Language Processing System Other Sources and
Programs
Other Sources Text Editor Debugger Which may be
& Programs • Another file or files you
Skeletal Source Program
created by text editor for
Preprocessor
this program
Source Program • Files generated by
Compiler
wizards, resource editors,
etc.. for this program
Target Assembly Program
• Files containing sections
Assembler of the code which can be
Relocatable machine code reused in your program
or Object Code • Files which should be
Linker
included in your source
Absolute Machine Code program to complete it.
Loader (e.g., header files)
Language Processing System Preprocessor
serves the following purposes
Other Sources Text Editor Debugger • Supports the use of
& Programs macros, that are
Skeletal Source Program shorthands of longer
Preprocessor constructs.
• Provide the ability to
Source Program
compile different sections
Compiler of the source file
Target Assembly Program depending on certain
conditions. (by PPD)
Assembler
Relocatable machine code • Allows file inclusion, A
section of the code written
or Object Code
Linker once & can be included in
other source files as
Absolute Machine Code
appropriate. (by PPD)
Loader (PPD: Preprocessor
Directives are instructions
to the PP, embedded in
source file)
• Language Processing System Source Program/Code
Is the program/code
Other Sources Text Editor Debugger written in high level
& Programs language.
Skeletal Source Program
Preprocessor

Source Program

Compiler
Target Assembly Program

Assembler
Relocatable machine code
or Object Code
Linker

Absolute Machine Code


Loader
• Language Processing System Compiler
Compilers translate the source
code into object code.
Other Sources Text Editor Debugger
& Programs
Skeletal Source Program Two parts of compilation phase
1. Analysis Phase
Preprocessor
• Linear or Lexical Analysis
Source Program (making Tokens)
• Hierarchical or Syntax
Compiler Analysis (Parsing)
Target Assembly Program • Semantic Analysis
Assembler • Intermediate code
generation
Relocatable machine code
2. Synthesis Phase
or Object Code • Code Optimization
Linker
• Code generation
Absolute Machine Code
Loader We will discuss the compilers
in detail in next lectures.
• Language Processing System Compiler (cont..)
• Some compilers produce
Text Editor Debugger
Assembly code that is
Other Sources
passed on to an
& Programs
Skeletal Source Program Assembler for further
Preprocessor
processing, Other
Compilers produces
Source Program Object Code that can be
passed directly to Linker.
Compiler
• Some Compilers have
Target Assembly Program both the options
Assembler depending on your
Relocatable machine code selection.
or Object Code
Linker

Absolute Machine Code


Loader
• Language Processing System Target Assembly
Program
Other Sources Text Editor Debugger Assembly Code is the
& Programs mnemonic version of
Skeletal Source Program machine code, in which
Preprocessor names are used instead of
binary code of operation and
Source Program names are also given to
Compiler memory locations.
Target Assembly Program
ST 1,[801] 00100101 11010011
ST 0,[802] 00100100 11010100
Assembler TOP: BEQ [802],10,BOT 10001010 01001001 11110000
Relocatable machine code 01000100
INCR [802] 01010100 01001000
or Object Code MUL [801],2,[803] 10100111 10100011
Linker 11100101 10101011
ST [803],[801] 00000010 00101001
Absolute Machine Code JMP TOP 11010101
BOT: LD A,[801] 11010100 10101000 10010001
Loader CALL PRINT 01000100
• Language Processing System Assembler
Translate Assembly language
Text Editor Debugger
Program into object code.
Other Sources
& Programs
Skeletal Source Program
Preprocessor

Source Program

Compiler
Target Assembly Program

Assembler
Relocatable machine code
or Object Code
Linker

Absolute Machine Code


Loader
• Language Processing System Object Code:
Machine language Instructions
Text Editor Debugger
which can be executed by
Other Sources
computer, however these
& Programs
Skeletal Source Program instructions are not
Preprocessor
complete executable
program.
Source Program

Compiler (Memory Addresses are not


absolute, it can be loaded
Target Assembly Program
starting at any location L in
Assembler memory, i.e., if L is added to
Relocatable machine code all addresses in code, This
allows the insertion of any
or Object Code
Linker length of other machine
language modules in the
Absolute Machine Code
code.)
Loader
• Language Processing System Linker
Make a Single Program from
several files of Object Code,
Other Sources Text Editor Debugger
& Programs These Object Files may be
Skeletal Source Program
• Results of several other
Preprocessor compilations
Source Program • One or more Library files of
routines provided by the
Compiler System and available to any
program that needs them.
Target Assembly Program
Other
Assembler Most of the time our program is
Object
Relocatable machine code using different routines and
Module functions that are located in
s or Object Code different files, hence it needs the
Linker
executable code of those
Library Absolute Machine Code routines/functions. Linker is a tool
Files which performs this job, it checks
Loader our program and includes all those
routines or functions which we are
using in our program to make a
standalone executable code
• Language Processing System Absolute Machine
Language Code
Other Sources Text Editor Debugger Is the program in machine
& Programs language, complete in all
Skeletal Source Program respect which can run on
Preprocessor computer standalone.

Source Program

Compiler
Target Assembly Program

Assembler
Relocatable machine code
or Object Code
Linker

Absolute Machine Code


Loader
• Language Processing System Loader:
After a executable program is
Text Editor Debugger
linked and saved on the disk
Other Sources
and it is ready for execution.
& Programs
Skeletal Source Program Loader loads the program
Preprocessor
into memory and then
instruct the processor to
Source Program start the execution of the
program from the first
Compiler instruction
Target Assembly Program

Assembler
Relocatable machine code
or Object Code
Linker

Absolute Machine Code


Loader
• Language Processing System Debugger
used to debug the program
i.e. to correct the Syntax
Other Sources Text Editor Debugger
and logical errors. Using
& Programs
Skeletal Source Program
debugger we can control our
program while it is running.
Preprocessor
We can stop the execution
Source Program of our program at some
point and can check the
Compiler values in different variables,
Target Assembly Program can change these values
etc. In this way we can trace
Assembler
the logical errors in our
Relocatable machine code program and can see
or Object Code whether our program is
Linker
producing the correct
Absolute Machine Code results.
Loader
IDE
(Integrated Development Environment)
An environment (package) in which you
can create a new application, modify it,
compile & link it, run it, debug it, all
without exiting.
Examples are Microsoft Visual C++,
Turbo C++ Explorer, CodeWarrior, etc.
What is a Program Made of?
• Common elements in programming
languages:
– Key Words
– Programmer-Defined Variables
– Operators
– Punctuation
– Syntax
Input, Processing, and Output
Three steps that a program typically
performs:
1) Gather input data:
• from keyboard
• from files on disk drives
2) Process the input data
3) Display the results as output:
• send it to the screen
• write to a file

You might also like