0% found this document useful (0 votes)
0 views

Foundations of Sequential Programs New

The document provides an overview of foundational concepts in sequential programming, including computer architecture, programming languages, and data representation. It discusses the components of a computer system, the minimalist approach to building a computer, and various architectures such as Von Neumann and Flynn's classification. Additionally, it covers machine levels, translators, and methods for representing data in binary form.

Uploaded by

dansnovamanga
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)
0 views

Foundations of Sequential Programs New

The document provides an overview of foundational concepts in sequential programming, including computer architecture, programming languages, and data representation. It discusses the components of a computer system, the minimalist approach to building a computer, and various architectures such as Von Neumann and Flynn's classification. Additionally, it covers machine levels, translators, and methods for representing data in binary form.

Uploaded by

dansnovamanga
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/ 33

FOUNDATIONS OF

SEQUENTIAL
PROGRAMS
Lecturers:
Dr. N. A. Azeez, Dr. R. A. Koleoso, and Mr S. E. Edagbami
Other Lecture Infomation

Lecture day Monday


Lecture time 2.00 PM – 4.00 PM
Lecture venue E303
RECOMMENDED TEXT BOOKS
Mano, M. Morris (1993).Computer System Architecture (3rd ed). Prentice Hall of
India.
Computer architecture From Wikipedia, the free encyclopedia 2014.
Von Neumann architecture From Wikipedia, the free encyclopedia
Computer Architecture and Organization Miles Murdocca and Vincent Heuring
Data Representation PDF.
Fundamentals of Computer Architecture Slides for Fundamentals of Computer
Architecture 1 © Mark Burrell, 2004
PROGRAMMING LANGUAGE
WHAT IS PROGRAMMING LANGUAGE ?
A programming language is a notation for writing programs, which are specifications
of a computation or algorithm.
The most basic (called low-level) computer language is the machine language
can run (execute) very fast without using any translator or interpreter program, but is
tedious and complex.
The Assembly language
The high-level languages (such as Basic, C, Java)- more 'English-like
COMPUTER ARCHITECTURE AND
CLASSIFICATION
WHAT IS COMPUTER ARCHITECTURE?
Computer architecture deals with the functional behavior of a
computer system as viewed by a programmer.
Computer architecture involves the design of computers.
Processor design involves the instruction set design and the
organisation of the processor.
INSIDE A COMPUTER

– The most important component is the processor. It runs


a series of instructions (called a program), and controls the
activity of all other components within the computer;
– Next we have the memory chips. These are used to store
our
data and instructions;
– The other labelled components include the hard disk, the
graphics card, network card and the power supply. All are
used by modern computer systems, but are actually quite
minor in the scale of things - we don’t need to refer to them
to learn how a computer works.
.

The Minimalist Approach (An Approach to


build a Computer System)

• What are the smallest number of components we need to build a computer? We


need:
– A processor - to process information, and to control the system;
– Memory - for data and instruction storage;
– Some form of input device; we’ll u a keyboard to enter data into the system;
– Some form of output device; we’ll use a monitor screen so we can see what our
computer is doing

The Minimalist Approach


•To build a simple processor we need the
following components:

– Some Registers - a register is a store where we can place


one piece of data;
– An Arithmetic Logic Unit, or ALU - a very basic calculator
for our processor. The ALU will have some registers inside
it, as we will see later;
– A Control Unit, or CU - to run the processor;
– Some buses - to allow us to move data from one
component to another
VON NEUMANN'S ARCHITECTURE

 All data and instructions are stored in the Main Memory


 Instructions are sent to the Processor along the System Bus to be
executed
 Any input and output (such as printing and entering instruction) is
performed by I/O devices with the data travelling from the I/O devices
to the Processor and Main Memory by means of the System Bus:
MEMORY

Main memory - data store that can be directly addressed by the CPU
Main memory is used to store program instruction and data, using the System
Bus to communicate with CPU. Main memory is often created using Random
Access Memory (or RAM) or Read Only Memory (ROM).
RAM - Random Access Memory can be read from and written to. Data is cleared
when the power is off
ROM - Read Only Memory can only be read from, data is maintained when the
power is off
The two main types of main memory are ROM and RAM. Whilst RAM might be
several gigabytes in size, ROM will often be a few kilobytes.
SYSTEM BUS
A Bus is a connection between different devices. This connection will normally
consist of multiple wires along which signals, instructions and data will be carried. In
Von Neumann Architecture there is a single bus to manage the connection between
the three main components. The System Bus consists of 3 separate buses, each with
a specific task that you need to know.

Address Bus: A single-directional bus that carries address signals from the CPU
to Main Memory and I/O devices. This might involve the CPU requesting some data
from Main Memory, sending the address of the data to Main Memory, then Main
Memory returning the data along the data bus. Let's take a look at some code:
LDA 23
BUS cont……..
Data bus: A bi-directional bus, typically consisting of 32 wires, used to transport
data and instructions between the three components of the three-box model. The
larger the Data Bus the more data can be transported at one time. For example if
we have an 8 bit Data Bus, the maximum value we could send along the Bus would
be: 1111 1111 = 255

Control bus: A bi-directional bus, typically consisting of more than 16 wires, used to
transport control signals between the three components of the three-box model.
The control bus is used to carry important information such as messages to say
when a device has finished a job or when a device has just been plugged in.
FLYNN’S CLASSIFICATION OF
COMPUTER ARCHITECTURES
Michael Flynn introduced a classification of various computer architectures
based on notions of instruction and data stream. The number of instruction is
given as either Single instruction (SI) or multiple instruction(MI) and the
numbers of data given as either single data(SD) or multiple data(MD).
Machine can be classified as
I. SINGLE INSTRUCTION SINGLE DATA (SISD)
II. MULTIPLE INSTRUCTION SINGLE DATA ( MISI)
III. SINGLE INSTRUCTION MULTIPLE DATA (SIMD)
IV. MULTIPLE INSTRUCTION MULTIPLE DATA (MIMD)
CONT…….

SINGLE INSTRUCTION SINGLE DATA (SISD)


The classical von Neumann machine can be regarded as a single-instruction-single-data
machine in that at any one time only a single instruction is being executed, and only a
single piece of data is being operated upon. This is where part of the problem arises, since
we often want to perform the same instruction on many different pieces of data, and the
von Neumann machine requires us to fetch the same instruction many times, once for
each piece of data.
 MULTIPLE INSTRUCTION SINGLE DATA
The multiple instruction single data (MISD) architecture is the most uncommon one. In this
architecture, the same data stream flows through a linear array of processors, executing
different instructions on the stream. This kind of architecture is also known as a systolic
array for pipelined execution of specific algorithms.
CONT………
SINGLE INSTRUCTION MULTIPLE DATA (SIMD)
For problems in which the same operation needs to be performed on many pieces of data,
particularly those involving vectors and arrays, SIMD (single-instruction multiple-data)
architectures are often capable of high speeds. A single CPU controls many arithmetic
units, each of which operates on its own data. Each arithmetic unit executes the same
instruction as determined by the CPU, but uses data found in its own memory.
MULTIPLE INSTRUCTION MULTIPLE DATA (MIMD)
The most general form of von Neumann architecture is the multiple-instruction-multiple-data
machine. A MIMD machine is usually a number of separate processors connected
together through some interconnection network. The actual format of interconnection
between the processors can take many forms, depending on the type of problem, which
the machine is designed to solve. This is the most common architecture chosen for
multiple processor machines because modern processors have the control logic for
parallel systems built in. Therefore, this is attractive since software, replacement parts and
additions to the system are easily accessible.
MACHINE LEVELS
Machines can have as many as six levels.
The lowest level is called the digital logic level, in this level, we have objects
called gates, composed of transistors. Each gate has one or more digital inputs
(signals representing 0 or 1) and computes as outputs some function such as
AND or OR. They can be used as registers, or combined for memory.
The next level is the microarchitecture level. This is a collection of 8 to 32
registers for memory and ALU (Arithmetic Logic Unit) to perform arithmetic and
logic operations. The registers are connected to the ALU to form a data path,
over which the data flow. The operation of the data path may be controlled by a
microprogram, directly by hardware, or even by software, in which case the
microprogram is the interpreter for instructions at the next level.
This level is called the Instruction set level (ISA level). This is a machine
language.
The next level is the operating system machine level.
The next level is the Assembly level language. Programs in assembly language
need to be translated into one of the lower level languages.
The final level is the problem-oriented language level. These are high-level
languages such as BASIC, Pascal, FORTRAN, COBOL, C++, Java, etc. They are
translated into lower level languages by compilers. Figure below explains these
six levels.
MACHINE LEVELS

Level 5 Problem oriented language level


|
| Translation (compiler)
|
Level 4 Assembly language level
|
| Translation (assembler)
|
Level 3 Operating system machine language
|
| Partial interpretation (operating system)
|
Level 2 Instruction set architecture level
|
| Interpretation (microprogram) or direct execution
|
Level 1 Microarchitecture level
|
| Hardware
|
Level 0 Digital logic level
TRANSLATORS
What is a Translator?
A translator takes a program written in source language as input and converts it
into a program in target language as output.
Roles of translator are:
• Translating the high-level language program input into an equivalent machine
language program.
• Providing diagnostic messages wherever the programmer violates specification
of the high-level language program.
BASIC TYPES OF TRANSLATOR
Assembler
An assembler translates assembly language into machine code. Assembly
language consists of mnemonics for machine opcodes so assemblers perform
a 1:1 translation from mnemonics to a direct instruction.

Interpreter
An interpreter program executes other programs directly, running through
program code and executing it line-by-line. As it analyses every line, an
interpreter is slower than running compiled code but it can take less time to
interpret program code than to compile and then run it.
Compiler
A Compiler is a computer program that translates code written in a high l e v e l
language to a lower level language, object/machine code. The most co m m o n
reason for translating source code is to create an executable p r o g r a m
(converting from a high level language into machine language).

****** WHAT ARE THE ADVANTAGES AND DISADVANTAGES OF THESE TYPE OF


TRANSLATORS
LINKER AND LOADER
WHAT IS A LINKER ?
In computing, a linker or link editor is a computer program that takes one or
more object files generated by a compiler and combines them into a single
executable file, library file, or another object file.

WHAT IS A LOADER
In computing, a loader is the part of an operating system that is responsible
for loading programs and libraries. It is one of the essential stages in the
process of starting a program, as it places programs into memory and
prepares them for execution. Loading a program involves reading the
contents of the executable f ile containing the program instructions into
memory, and then carrying out other required preparatory tasks to prepare
the executable for running. Once loading is complete, the operating system
starts the program by passing control to the loaded program code.
DATA REPRESENTATION
How is information represented in a computer? It is in the form of a binary digit
popularly called bit. But how are the arithmetical calculations performed through
these bits? How then are words like ABCD stored in the computer?
Number Systems
A number system of base (also called radix) r is a system which has r distinct
symbols for r digits. A string of these symbolic digits represents a number. To
determine the quantity that the number represents, we multiply the number by
an integer power of r depending on the place in which it is located and then f ind
the sum of weighted digits.
NUMBER SYSTEM…..
Decimal Numbers: The decimal number system has ten digits represented by
0,1,2,3,4,5,6,7,8 and 9. Any decimal number can be represented as a string of
these digits and since there are ten decimal digits, therefore, the base or radix of
this system is 10.
Binary Numbers: In binary numbers we have two digits 0 and 1 and they can
also be represented, as a string of these two-digits called bits. The base of the
binary number system is 2.
Octal Numbers: An octal system has eight digit represented as 0, 1, 2, 3, 4, 5, 6, 7.
For finding the equivalent decimal number of an octal number one has to find
the quantity of the octal number, which is again calculated as:
Octal number (23.4)8
Hexadecimal Numbers: The hexadecimal system has 16 digits, which are
represented as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. A number (F2)H is
equivalent to F x 161 + 2 x 160 = (15 x 16) + 2
Computational Data Representation
The computer is a discrete digital device and it stores information in flip-flops
which are two state devices, in binary form. Basic requirements of
computational data representation in binary form are:
Representation of sign;
Representation of magnitude;
If the number is fractional, then binary or decimal point, and exponent
sign can be either positive or negative, therefore, one bit can be used to
represent a sign. By default it should be the leftmost bit. n bit can be
represented as n+1 bit number, where n+1th bit is the sign bit and the rest n bits
represent its magnitude

1 bit n bits
sign Magntitude
Complement
Complement: There are two types of complements for a number of base r;
these are called r’s complement and (r- 1)’s complement. For example, for
decimal numbers the base is 10, therefore, complements will be 10’s
complement and (10-1) = 9’s complements. For binary numbers we talk about
2’s and 1’s complements. But how are we to obtain complements and what do
these complements mean? Let us discuss these issues with the help of
following example:
Example 1: Find the 9’s complement and 10’s complement for the decimal
number 256.
9’s complement of 256 = 9 9 9
-2 -5 -6
= 7 4 3
10’s complement: adding 1 in the 9’s complement produces the 10’s
complement:
10’s complement of 256 = 743 + 1 = 744
Example 3: Find 1’s and 2’s complement of 1010
1 1 1 1
-1 -0 -1 -0
0 1 0 1

The number is 1 0 1 0
The 1’s complement is 0 1 0 1
Negative Numbers
How to represent -1, -2, … on a computer?

Solution 1: use an extra bit to represent the negative sign


It is called the sign bit, in front of numbers
Usually, 0 is for positives; 1 is for negatives
Example: 1 0001 is -1 and 0 0100 is +4
Note: The sign bit does not carry value (it is not part of the value)
4 bits Representation
Decimal Hexadecimal Binary
+0 0 0 000
+1 1 0 001
+2 2 0 010
+3 3 0 011
+4 4 0 100
+5 5 0 101
+6 6 0 110
+7 7 0 111
-0 8 1 000
-1 9 1 001
-2 A 1 010
-3 B 1 011
-4 C 1 100
-5 D 1 101
-6 E 1 110
-7 F 1 111
Overflow
Suppose computer only allow 4 bits
What is 5+4?
This is called overflow
Adding two positive (negative) numbers results in a negative (positive) number
The Fixed Point Representation
The fixed-point numbers in binary use a sign bit. A positive number has a sign bit
0, while the negative number has a sign bit 1. In the fixed-point numbers we
assume that the position of the binary point is at the end. It implies that all the
represented numbers should be integers. A negative number can be
represented in one of the following ways.
Signed magnitude representation,
Signed 1’s complement representation, or
Signed 2’s complement representation.
(Assumption size of register = 7 bit, the 8th bit is used for error checking and
correction or other purposes).
Example: Add 25 and – 30 in binary using a 7 bit
register in
signed magnitude representation
signed 1’s complement
signed 2’s complement
+25 0 011 001
+30 0 011 110
+55 0 110 111 +5 is 0 000 101
-5 is 1 111 011
+25 0 011 001 in 2’s complement representation
-30 1 100 110
-05 1 111 011 (Just add the two numbers)

-25 1 100 001


+30 0 011 110

+05 1 0 000 101 (Just add the two numbers)


What Characterizes a Programming
Language : Paradigms
Imperative programming:
Fortran, Cobol, Algol, PL/I, C, Pascal, Ada, C++, Icon, Modula-2, Modula-3, Oberon,
Basic.
Concurrent programming:
Ada, Occam, Par-C.
Object-oriented programming:
Small-talk, Self, C++, Objective-C, Object Pascal, Beta, CLOS, Eiffel
Functional programming:
Lisp, Scheme, Miranda, ML.
Logic programming:
Prolog, Prolog-dialects, Turbo-Prolog, Icon.

You might also like