CS251-lecture2

advertisement
Riyadh Philanthropic Society For Science
Prince Sultan College For Woman
Dept. of Computer & Information Sciences
CS 251
Introduction to Computer Organization
& Assembly Language
Lecture 2
(Structured Computer Organization)

From text Book: Chapter 1 (1.1.1, 1.1.2)

Structured Computer Organization

Languages & Levels

Virtual Machines

Contemporary Multilevel Machine
 6 Layers representation
Structured Computer Organization
2

A computer is a machine that solves problems by executing instructions given to it.

The set or a group of instructions constitute a program.

The computer only understands machine language: a limited set of simple
instructions that the internal electronic circuitry can comprehend.
 It is composed of fairly simple instructions (ex. Add, check output value, compare …)
 This simplicity is due to the need to reduce the complexity & cost of the electronics
 All programs have to be converted to machine language before being executed
Structured Computer Organization
3

Structuring the computer as a series of abstraction layers

Each layer builds upon the one below it.

The complexity could be decomposed and mastered

Systematic and organized way to design computer systems
Structured Computer Organization
Structured Computer Organization
4
 There is a gap between what humans want and what the computer understands.
 The more understandable human instructions form a language L1.
 The built-in machine instructions form a language L0.
 To facilitate the operation of the computer on humans, L1 is used to give instructions.

But computers only understands the L0 instructions
Translation OR Interpretation
Structured Computer Organization
5

Replaces each instruction in L1 by an equivalent sequence of
instructions in L0.


The entire L1 program is converted into an L0 program
The newly generated L0 program is the one that is executed

Moving completely from one language to another
Structured Computer Organization
6

It is the process carried out by the interpreter

The interpreter:

Is a program written in L0

Takes the L1 program as input data

Examines each L1 instruction in turn and executes the equivalent sequence of L0
instructions directly

After each L1 instruction is examined and decoded, it is carried out immediately

No new L0 program in generated.
Structured Computer Organization
7

Hypothetical computer or virtual machine M1 whose machine language is L1.

The virtual machine for L0 is M0.

If M1 could be constructed cheaply enough (not the case)
 People could write their programs in L1 and have the computer execute them directly
(no need for M0 executing programs in L0).

If M1 is too expensive or complicated to construct
 People can write programs for M1, just as though it really exist these programs can be
translated or interpreted to L0.
Structured Computer Organization
8


For practical translation or interpretation, the languages L0 and L1 mustn’t be too different.
This means that L1 although better than L0, will still be far from ideal for most applications.
Question:
How do we relieve the programmer of the burden of having
to express a language more suited to machine than people?
Structured Computer Organization
9

Invent another set of instructions that is more people-oriented and less machineoriented than L1. Lets call it L2.

The invention of a whole series of languages, each one more human convenient
than its predecessors.

Each language uses its predecessor as a basis, so we may view a computer using
this technique as a series of layers or levels, one on top of another.

The bottommost language or level is the simplest and the highest language or level
is the most sophisticated.
Structured Computer Organization
10
Programs in Ln are either interpreted by
interpreter running on a lower machine,
or are translated to the machine language
of a lower machine
Level n
Virtual machine Mn, with
machine language Ln
Level 3
Virtual machine M3, with
machine language L3
Level 2
Virtual machine M2, with
machine language L2
Programs in L2 are either interpreted by
interpreter running on M1 or M0, or are
translated to L1 or L0.
Level 1
Virtual machine M1, with
machine language L1
Programs in L1 are either interpreted by
interpreter running on M0, or are
translated to L0.
Level 0
Virtual machine M0, with
machine language L0
Programs in L0 can be directly executed
by the electronic circuits.
Structured Computer Organization
11

An n level machine comprises n different virtual machines and n different
languages.

When working on a layer n, there is no need to know about the underlying
interpreter or translator

The machine structure insures that the upper level language instructions are
converted into the lower levels and executed simultaneously.
Structured Computer Organization
12

Most modern computers are designed with somewhere between 2-6 layers.
 Level 0: Digital Logic Level
 Level 1: Micro-architecture level
 Level 2: Instruction Set Architecture level
 Level 3: Operating system machine level
 Level 4: Assembly Language level
 Level 5: Problem-oriented language level
Structured Computer Organization
13
Level 5
Problem-oriented language level
Translation (compiler)/interpretation
Level 4
Assembly language level
Translation (assembler)
Level 3
Operating system machine level
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
Structured Computer Organization
14

It is a hardware level whose basic components are called gates

Each gate is built up of at most a handful of transistors.

Each gate has one or more digital inputs (signals representing 0 or 1) and
computes as output some simple functions of these inputs, such as AND or OR.
Structured Computer Organization
15

A number of gates can be combined to form a 1-bit memory, which can store a 0 or 1.

The 1-bit memories can be combined in groups of 16, 32, or 64 to form registers.

Each register can hold a single binary number up to some maximum

Gates can also be combined to form the main computing engine itself.
Structured Computer Organization
16

It is composed of local memory (a set of 8 to 32 registers) and the ALU

It performs simple arithmetic operations such as addition, OR, AND …..

The registers are connected to the ALU to form a data path, over which the data flow.

The basic operation of the data path consists of selection one or two registers having
the ALU operate on them.
But how is this data path controlled ?
Structured Computer Organization
17

The operation of the data path is controlled by Control Unit:

Control unit can have two organizations:
 CU controlled directly by hardware
 CU controlled by Software through a program called the micro-program

The micro-program is an interpreter for the instructions at level 2.
 It fetches, examines, and executes instructions one by one, using data path to do so.

For Hardwired control of the data path, the same steps for executing an instruction are
followed, but without the explicit stored program to control the interpretation
Structured Computer Organization
18


The machines instruction set is designated by the H/W manufacture.
Every computer manufacturer publishes a manual for each of its computer it sells,
entitled “Machine Language Reference Manual”


These manuals are really about the ISA level.
The set describes the instructions carried out interpretively by the micro-program
or H/W execution circuits.
Structured Computer Organization
19

It is a hybrid level with instructions overlapping with the ISA level.

Some of the level 3 instructions are interpreted by the operating system and some are
interpreted directly by micro program ( or hardwired control).

It constitutes of:
 Instructions identical to level 2
 Various other features:
 A set of new instructions
 Different memory organization
 The ability to run two or more programs concurrently ( carried out by an interpreter called
operating system)
Structured Computer Organization
20
Level 1,2, & 3
Levels 4 & 5
Intended for system programmers who
specialize in designing and
implementing new virtual machines
Intended for application programmers
with a problem to solve
The machine languages of these levels
are numeric (long series of numbers)
Languages of these levels contain
words and abbreviations meaningful
to people
Level 2 and 3 are always interpreted
Usually (not always) supported by
translation
Structured Computer Organization
21
s[i] = temp
s[i] = s[i+1]
s[i+1] = temp
High Level Language
Program (e.g. Java)
Compiler
lw $t0,
lw $t1,
sw $t1,
sw $t0,
Assembly Language
Program (e.g. MIPS)
0($2)
4($2)
0($2)
4($2)
Assembler
Machine Language
Program (i.e. bits)
0000
1010
0100
1011
1010
1111
0010
1101
1000
1001
1011
1100
0100
1010
0110
0011
1110
1101
1100
1011
1111
0010
0001
1110
Machine
Interpretation
Course Introduction
22

A symbolic form for one of the underlying languages.

This level provides a method for people to write programs for levels 1, 2, and 3 in a
form that is not unpleasant as the virtual machine languages themselves.

Programs in assembly language are first translated (by the assembler) to level 1,2,
or 3 language and then interpreted by the appropriate virtual or actual machine.
Structured Computer Organization
23

Usually consists of languages designed to be used by application programmers.

Such languages are often called high-level languages, ex. Pascal, FORTRAN, JAVA,
C++, …etc.

Programs written in these languages are generally translated to level 3 or level 4 by
translators known as compilers (although occasionally they are interpreted, ex. JAVA).
Structured Computer Organization
24

The set of data types, operations, and features of each level is called its architecture.

The architecture deals with those aspects that are visible to the user of that level (ex.
How much memory is available).

Implementation aspects, such as what kind of chip technology is used to implement
the memory, are not part of the architecture.

The study of how to design those parts of a computer system that are visible to the
programmers is called computer architecture.
 Computer architecture = computer organization
Structured Computer Organization
25
Download