0% found this document useful (0 votes)
14 views11 pages

Lecture 2

Jj

Uploaded by

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

Lecture 2

Jj

Uploaded by

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

computer architecture and organization CHARTER 1

Dr. Rasha Abd El-naby

2022-2023

1
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

1.4 Software

The hardware components of a computer system are electronic devices in


which the basic unit of information is either a 0 or a 1, corresponding to two states
of an electronic signal. For instance, in one of the popular hardware technologies a
0 is represented by 0V while a 1 is represented by 5 V. Programs and data must
therefore be expressed using this binary alphabet consisting of 0 and 1. Programs
written using only these binary digits are machine language programs. At this level
of programming, operations such as ADD and SUBTRACT are each represented
by a unique pattern of 0s and 1s, and the computer hardware is designed to
interpret these sequences. Programming at this level is tedious since the
programmer has to work with sequences of 0s and 1s and needs to have very
detailed knowledge of the computer structure.

The tedium of machine language programming is partially alleviated by


using symbols such as ADD and SUB rather than patterns of 0s and 1s for these
operations. Programming at the symbolic level is called assembly language
programming.
An assembly language programmer also is required to have a detailed knowledge
of the machine structure, because the operations permitted in the assembly
language are primitive and the instruction format and capabilities depend on the
hardware organization of the machine. An assembler program is used to translate
assembly language programs into machine language.

Use of high-level programming languages such as FORTRAN, COBOL, C,


and JAVA further reduces the requirement of an intimate knowledge of the
machine organization. A compiler program is needed to translate a high-level

1
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

language program into the machine language. A separate compiler is needed for
each high level language used in programming the computer system. Note that the
assembler and the compiler are also programs written in one of those languages
and can translate an assembly or high-level language program, respectively, into
the machine language.

Figure 1.1 The difference between the machine language and assembly language and
the high level language

The Machine Language “low-level language”


Low-Level language is the only language which can be understood by the
computer. Low-level language is also known as Machine Language. The machine
language contains only two symbols 1 & 0. All the instructions of machine
language are written in the form of binary numbers 1's & 0's. A computer can
directly understand the machine language.

The Assembly Language “middle-level language”

Middle-level language is a computer language in which the instructions are created


using symbols such as letters, digits and special characters. Assembly language is

2
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

an example of middle-level language. In assembly language, we use predefined


words called mnemonics. Binary code instructions in low-level language are
replaced with mnemonics and operands in middle-level language. But the
computer cannot understand mnemonics, so we use a translator
called Assembler to translate mnemonics into machine language.

Assembler is a translator which takes assembly code as input and produces


machine code as output. That means, the computer cannot understand middle-level
language, so it needs to be translated into a low-level language to make it
understandable by the computer. Assembler is used to translate middle-level
language into low-level language.

The High level language

High-level language is a computer language which can be understood by the users.


The high-level language is very similar to human languages and has a set of
grammar rules that are used to make instructions more easily. Every high-level
language has a set of predefined words known as Keywords and a set of rules
known as Syntax to create instructions. The high-level language is easier to
understand for the users but the computer can not understand it. High-level
language needs to be converted into the low-level language to make it
understandable by the computer. We use Compiler or interpreter to convert high-
level language to low-level language.

Languages like FORTRAN,C, C++, JAVA, Python, etc., are examples of high-
level languages. All these programming languages use human-understandable
language like English to write program instructions. These instructions are
converted to low-level language by the compiler or interpreter so that it can be
understood by the computer.
3
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

Figure 1.2 shows the sequence of operations that occurs once a program is
developed. A program written in either the assembly language or a high-level
language is called a source program. An assembly language source program is
translated by the assembler into the machine language program. This machine
language program is the object code. A compiler converts a high-level language
source into object code. The object code ordinarily resides on an intermediate
device such as a magnetic disk or tape. A loader program loads the object code
from the intermediate device into the memory unit. The data required by the
program will be either available in the memory or supplied by an input device
during the execution of the program. The effect of program execution is the
production of processed data or results.

Figure 1.2 Program translation and execution

4
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

Difference between assembly language and high-level language :

Parameter Assembly Language High-Level Language

Assembly language is a computer High-level language is a


programming language in which computer program
Definition abbreviated keywords are used to language in which English
write instruction codes. like statements are used
to write codes.

A language translator called High-level language


“assembler” is required to convert requires an interpreter or
Language the assembly language code into the a compiler to convert the
translator machine code. high-level language codes
into the executable
machine codes.

Assembly language is a low-level High-level language, as


Level of
language. the name implies, is high-
language
level language.

Assembly language is less High-level language is


Programmer
programmer friendly programming highly user friendly
friendliness
language. programming language.

Computer instructions written in Computer instructions


Speed of
assembly language execute faster. written in high-level
execution
language execute slower.

Machine Assembly language is machine High-level language is


dependency dependent. machine independent.

5
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

Assembly language is more prone to The chances of errors in


Prone to
errors. high-level languages are
error
less.

Assembly language codes require High-level language codes


Memory
less memory space. require more memory
requirement
space.

The length of executable codes in The length of executable


Code length assembly language is shorter. codes in high-level
language is longer.

Assembly language codes are High-level language codes


Debug relatively difficult to debug. It is more are very easy to debug.
challenging and time- consuming.

Assembly language is a complex High-level languages are


programming language, as to write easy to write codes
the instruction codes in assembly without much knowledge
Complexity
language, the programmer must about the computer
have a deep understanding of hardware and
hardware and system architecture. architecture.

Assembly language codes are more High-level language codes


efficient. are less efficient, as the
Efficiency
coder has less control over
the underlying hardware.

The readability of assembly language High-level language codes


Readability
codes is less. are more readable.

Assembly language programs take High-level language


Developmen
more time and effort to develop. programs require less
t time &
development time and
effort
effort.

Memory Assembly language codes require High-level language codes


managemen manual memory management. provide automatic

6
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

t memory management.

Assembly language uses symbolic High-level languages use


representation of machine codes. keywords and statements
Syntax
similar to English
language.

Assembly language is primarily used High-level languages are


to program processors, mainly used for
Applications microcontrollers, embedded systems, developing software
device drivers, etc. applications, web
applications, etc.

Compiler: Transforming Code into Machine Language Magic

Definition:

A compiler is a specialized program that translates the entire source code of a


program written in a high-level programming language into machine code or an
intermediate code. This translation is done before the program is

Key Characteristics:

1. One-Time Translation: A compiler translates the entire source code


at once, creating an executable file. This file can be executed multiple
times without the need for re-translation unless changes are made to
the code.

2. Efficiency: Compiled code tends to be more efficient in terms of


execution speed because the translation has already been performed,

7
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

and the machine code is directly executed by the computer’s


hardware.

3. Examples:

 GCC (GNU Compiler Collection): Used for compiling programs


written in languages like C, C++, and Fortran.

 Java Compiler (javac): Translates Java source code into bytecode,


which is then executed by the Java Virtual Machine (JVM).

Interpreter:

Definition:

An interpreter is a program that reads and executes the source code of a program
line by line, translating and executing each line immediately. There’s no
intermediate machine code generated beforehand.

Key Characteristics:

1. Line-by-Line Execution: Unlike a compiler, an interpreter executes


code line by line at runtime. It reads a line, translates it, and
immediately performs the corresponding actions.

8
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

2. Dynamic Nature: Interpreters are more adaptable to changes in the


code, as they can immediately execute modified code without the
need for a separate compilation step.

3. Examples:

 Python Interpreter: Interprets and executes Python code interactively


or from scripts.

 Node.js (JavaScript Interpreter): Allows the execution of JavaScript


code on the server side, interpreting and executing it dynamically.

Comparing Compiler and Interpreter:

Compilation vs Interpretation:

 Compilation: Translates the entire source code before execution.

 Interpretation: Translates and executes code line by line at runtime.

Execution Speed:

 Compilation: Generally results in faster execution since the


translation is done beforehand.

 Interpretation: May have a slightly slower execution speed as


translation happens dynamically.

Debugging:

9
computer architecture and organization CHARTER 1
COMPUTER ARCHITECTURE AND ORGANIZATION CHARTER 1

 Compilation: Debugging can be more challenging as the entire


program is translated before execution.

 Interpretation: Allows for easier debugging, as errors are


encountered and reported line by line.

Examples:

 Compilation: GCC, Java Compiler (javac).

 Interpretation: Python Interpreter, JavaScript Interpreter (Node.js).

10

You might also like