Sugabal Assignment 3
Sugabal Assignment 3
Sugabal Assignment 3
ASSIGNMENT III
SUGABALAN K
B.Com (CA)
2101AP10134
PRIST UNIVERISTY
THANJAVUR CAMPUS
A programming language defines a set of instructions that are compiled together to perform a specific
task by the CPU (Central Processing Unit). The programming language mainly refers to high-level languages
Each programming language contains a unique set of keywords and syntax, which are used to create a set
of instructions. Thousands of programming languages have been developed till now, but each language has
its specific purpose. These languages vary in the level of abstraction they provide from the hardware.
Some programming languages provide less or no abstraction while some provide higher abstraction.
Based on the levels of abstraction, they can be classified into two categories:
o Low-level language o
High-level language
The image which is given below describes the abstraction level from hardware. As we can observe from the
below image that the machine language provides no abstraction, assembly language provides less
The low-level language is a programming language that provides no abstraction from the hardware, and it
is represented in 0 or 1 forms, which are the machine instructions. The languages that come under this
The machine-level language is a language that consists of a set of instructions that are in the binary form
0 or 1. As we know that computers can understand only machine instructions, which are in binary digits,
i.e., 0 and 1, so the instructions given to the computer can be only in binary codes. Creating a program in a
machine-level language is a very difficult task as it is not easy for the programmers to write the program
in machine instructions. It is error-prone as it is not easy to understand, and its maintenance is also very
high. A machine-level language is not portable as each computer has its machine instructions, so if we write
The different processor architectures use different machine codes, for example, a PowerPC processor
contains RISC architecture, which requires different code than intel x86 processor, which has a CISC
architecture.
Assembly Language
The assembly language contains some human-readable commands such as mov, add, sub, etc. The problems
which we were facing in machine-level language are reduced to some extent by using an extended form of
machine-level language known as assembly language. Since assembly language instructions are written in
English words like mov, add, sub, so it is easier to write and understand.
As we know that computers can only understand the machine-level instructions, so we require a translator
that converts the assembly code into machine code. The translator used for translating the code is known
as an assembler.
The assembly language code is not portable because the data is stored in computer registers, and the
machine language in the hierarchy, so it means that assembly language has some abstraction from the
The following are the differences between machine-level language and assembly language:
High-Level Language
The high-level language is a programming language that allows a programmer to write the programs which
are independent of a particular type of computer. The high-level languages are considered as highlevel
When writing a program in a high-level language, then the whole attention needs to be paid to the logic of
the problem.
A compiler is required to translate a high-level language into a low-level language.
Advantages of a high-level language o The high-level language is easy to read, write, and maintain as
o The high-level languages are designed to overcome the limitation of low-level language, i.e.,
portability. The high-level language is portable; i.e., these languages are machine-independent.
The following are the differences between low-level language and high-level language:
Machine code, also known as machine language, is the elemental language of computers. It is read by the
computer's central processing unit (CPU), is composed of digital binary numbers and looks like a very long
sequence of zeros and ones. Ultimately, the source code of every human-readable programming language
must be translated to machine language by a compiler or an interpreter, because binary code is the only
Each CPU has its own specific machine language. The processor reads and handles instructions, which tell
the CPU to perform a simple task. Instructions are comprised of a certain number of bits. If instructions for
a particular processor are 8 bits, for example, the first 4 bits part (the opcode) tells the computer what to
do and the second 4 bits (the operand) tells the computer what data to use.
Depending upon the processor, a computer's instruction sets may all be the same length, or they may vary,
depending upon the specific instruction. The architecture of the particular processor determines how
instructions are patterned. The execution of instructions is controlled by firmware or the CPU's internal
wiring.
Human programmers rarely, if ever, deal directly with machine code anymore. If developers are debugging
a program at a low level, they might use a printout that shows the program in its machine code form. The
printout, which is called a dump, is very difficult and to work with a tool called a dump. Utility programs
used to create dumps will often represent four bits by a single hexadecimal to make the machine code
easier to read and contain other information about the computer's operation, such as the address of the
instruction that was being executed at the time the dump was initiated.
Binary language of computers is defined as a combination of zeros and ones, which forms the most
fundamental layer of information that is stored in computing systems. Learn an overview of binary
Definition
All data in a computer system consists of binary information. 'Binary' means there are only 2 possible
values: 0 and 1. Computer software translates between binary information and the information you
actually work with on a computer such as decimal numbers, text, photos, sound, and video. Binary
information is sometimes also referred to as machine language since it represents the most fundamental
At a physical level, the 0s and 1s are stored in the central processing unit of a computer system using
transistors. Transistors are microscopic switches that control the flow of electricity. If a current passes
through the transistor (the switch is closed), this represents a 1. If a current doesn't pass through (the
Binary information is also transmitted using magnetic properties; the two different types of polarities are
used to represent zeros and ones. An optical disk, such as a CD-ROM or DVD, also stores binary information
in the form of pits and lands (the area between the pits).
No matter where your data is stored, all digital data at the most fundamental level consists of zeros and
ones. In order to make sense of this binary information, a binary notation method is needed, also referred
to a binary code.
Binary Notation
Each binary digit is known for short as a bit. One bit can only be used to represent 2 different values: 0 and
1. To represent more than two values, we need to use multiple bits. Two bits combined can be used to
represent 4 different values: 0 0, 0 1, 1 0, and 1 1. Three bits can be used to represent 8 different values: 0
values.
Consider the example of representing the decimal numbers 0 through 10. There are more than 8 unique
values to represent, which will, therefore, require a total of 4 bits (since 3 bits can only represent 8 different
values). The table shows the binary equivalent for the numbers 0 through 10. This is an example of
To represent larger numbers, you need more bits. Modern computers use a 32-bit or 64-bit architecture.
This represents the maximum number of binary digits that can be used to represent a single value. A total
of 32 bits can be used to represent 2^32 different values. The equivalent of this in decimal notation is
4,294,967,295. This is the largest number that can be used without resulting in rounding issues.
Want to see what this really means? Use a computer application that works with numbers such as Excel.
Type a really large number. If your operating system is 32-bit, after 10 digits, the next digits will be rounded
to 0. There are ways around this, but the number of bits provides a physical limit to how many unique digits
Binary Coding
The same logic used to represent numbers can be used to represent text. What we need is a coding scheme,
similar to the binary notation example for the numbers 0 through 10. How many characters do we need to
represent text? The English language includes 26 letters. Upper and lower case have to be treated
separately, so that makes 52 unique characters. We also need characters to represent punctuation, numeric
A basic set may only need about 100 characters or so, very much like the keys on a keyboard, but what
about different languages that use a different script? All the characters we want to represent are known as
a character set. Several standard character sets have been developed over the years, including ASCII and
Unicode.
ASSEMBLY LANGUAGE
The assembler language is the symbolic programming language that lies closest to the machine language
• You need to control your program closely, down to the byte and even the bit level.
• You must write subroutines for functions that are not provided by other symbolic programming
The assembler language is made up of statements that represent either instructions or comments. The
instruction statements are the working part of the language and are divided into the following three
groups:
• Machine instructions
• Assembler instructions
• Macro instructions
A machine instruction is the symbolic representation of a machine language instruction of the following
instruction sets:
• IBM System/370
(ESA/390)
• z/Architecture®
It is called a machine instruction because the assembler translates it into the machine language code that
the computer can run. Machine instructions are described in Machine instruction statements.
An assembler instruction is a request to the assembler to do certain operations during the assembly of a
source module; for example, defining data constants, reserving storage areas, and defining the end of the
source module. Except for the instructions that define constants, and the instruction used to generate
nooperation instructions for alignment, the assembler does not translate assembler instructions into object
code. The assembler instructions are described in Program structures and addressing , Assembler
instruction statements, and How to write conditional assembly instructions.
A macro instruction is a request to the assembler program to process a predefined sequence of instructions
called a macro definition. From this definition, the assembler generates machine and assembler
instructions, which it then processes as if they were part of the original input in the source module.
IBM supplies macro definitions for input/output, data management, and supervisor operations that you
can call for processing by coding the required macro instruction. (These IBM-supplied macro instructions
You can also prepare your own macro definitions, and call them by coding the corresponding macro
instructions. Rather than code all this sequence each time it is needed, you can create a macro instruction
to represent the sequence and then, each time the sequence is needed, code the macro instruction
statement. During assembly, the sequence of instructions represented by the macro instruction is inserted
instruction.
High Level Assembler operates under the z/OS operating system, the CMS component of the z/VM
operating system, the z/VSE operating system, and Linux for System z®. These operating systems provide
In writing a source module, you must include instructions that request any required service functions from
o A control program o
Libraries to contain
definitions o Utilities
• For preparing for the execution of the assembler program as represented by the object module:
o A control program
o Storage allocation o Input and
Loader
code o Libraries to
definitions o Utilities
• For preparing for the execution of the assembler program as represented by the object modules:
o Storage allocation o
facilities o Linker o A
loader
o A control program o
Libraries to contain
definitions o Utilities
• For preparing for the execution of the assembler program as represented by the object module:
facilities o Linker
Linux for System z provides the following services:
code o Utilities
• For preparing for the execution of the assembler program as represented by the object modules:
o Storage allocation o
facilities o Linker o A
loader
It can be difficult to write an assembler language program using only machine instructions. The assembler
provides additional functions that make this task easier. Here is a summary of these additional functions:
• Relocatability
• Sectioning a program
• Program listings
If you code the correct assembler instruction, the assembler computes the relative offset, or displacement
from a base address, of any symbolic addresses you specify in a machine instruction. It inserts this
displacement, along with the base register assigned by the assembler instruction, into the object code of
basedisplacement form. The computer obtains the required address by adding the displacement to the base
address contained in the base register, or from the relative-immediate offset of the instruction.
The assembler produces an object module that is independent of the location it is initially assigned in
virtual storage. That is, it can be loaded into any suitable virtual storage area without affecting program
execution. This is made easier because most addresses are assembled in their base-displacement form.
You can divide a source module into one or more control sections. After assembly, you can include or delete
individual control sections from the resulting object module before you load it for execution. Control
sections can be loaded separately into storage areas that are not contiguous. A discussion of
The assembler produces a listing of your source module, including any generated statements, and the
object code assembled from the source module. You can control the form and content of the listing using
assembler listing control instructions, assembler options, and user I/O exits. The listing control
instructions are described in Assembler instruction statements, and in Processing statements. Assembler
options and user I/O exits are discussed in the chapters "Controlling Your Assembly with
Options" and "Providing User Exits" in the HLASM Programmer's Guide.You can create symbolic linkages
between separately assembled source modules. This lets you refer symbolically from one source module
to data and instructions defined in another source module. You can also use symbolic addresses to branch
between modules.
"High-level language" refers to the higher level of abstraction from machine language. Rather than dealing
with registers, memory addresses, and call stacks, high-level languages deal with variables, arrays, objects,
complex arithmetic or boolean expressions, subroutines and functions, loops, threads, locks, and other
abstract computer science concepts, with a focus on usability over optimal program efficiency. Unlike low-
level assembly languages, high-level languages have few, if any, language elements that translate directly
into a machine's native opcodes. Other features, such as string handling routines, object-oriented language
features, and file input/output, may also be present. One thing to note about high-level programming
languages is that these languages allow the programmer to be detached and separated from the machine.
That is, unlike low-level languages like assembly or machine language, highlevel programming can amplify
the programmer's instructions and trigger a lot of data movements in the background without their
knowledge. The responsibility and power of executing instructions have been handed over to the machine
High-level languages intend to provide features which standardize common tasks, permit rich debugging,
and maintain architectural agnosticism; while low-level languages often produce more efficient code
through optimization for a specific system architecture. Abstraction penalty is the cost that high-level
programming techniques pay for being unable to optimize performance or use certain hardware because
they don't take advantage of certain low-level architectural resources. High-level programming exhibits
features like more generic data structures and operations, run-time interpretation, and intermediate code
files; which often result in execution of far more operations than necessary, higher memory
consumption, and larger binary program size.[6][7][8] For this reason, code which needs to run particularly
quickly and efficiently may require the use of a lower-level language, even if a higher-level language would
make the coding easier. In many cases, critical portions of a program mostly in a high-level language can
be hand-coded in assembly language, leading to a much faster, more efficient, or simply reliably functioning
optimised program.
However, with the growing complexity of modern microprocessor architectures, well-designed compilers
for high-level languages frequently produce code comparable in efficiency to what most low-level
programmers can produce by hand, and the higher abstraction may allow for more powerful techniques
providing better overall results than their low-level counterparts in particular settings.[9] High-level
languages are designed independent of a specific computing system architecture. This facilitates executing
a program written in such a language on any computing system with compatible support for the
Interpreted or JIT program. High-level languages can be improved as their designers develop
improvements. In other cases, new high-level languages evolve from one or more others with the goal of
aggregating the most popular constructs with new or improved features. An example of this is Scala which
maintains backward compatibility with Java which means that programs and libraries written in Java will
continue to be usable even if a programming shop switches to Scala; this makes the transition easier and
the lifespan of such high-level coding indefinite. In contrast, low-level programs rarely survive beyond the
system architecture which they were written for without major revision. This is the engineering 'trade-off'
The terms high-level and low-level are inherently relative. Some decades ago, the C language, and similar
languages, were most often considered "high-level", as it supported concepts such as expression
evaluation, parameterised recursive functions, and data types and structures, while assembly language was
considered "low-level". Today, many programmers might refer to C as low-level, as it lacks a large runtime-
system (no garbage collection, etc.), basically supports only scalar operations, and provides direct memory
addressing. It, therefore, readily blends with assembly language and the machine level of CPUs and
microcontrollers.
Assembly language may itself be regarded as a higher level (but often still one-to-one if used without
macros) representation of machine code, as it supports concepts such as constants and (limited)
expressions, sometimes even variables, procedures, and data structures. Machine code, in its turn, is
inherently at a slightly higher level than the microcode or micro-operations used internally in many
processors
There are three general modes of execution for modern high-level languages:
Interpreted
When code written in a language is interpreted, its syntax is read and then executed directly, with no
compilation stage. A program called an interpreter reads each program statement, following the
program flow, then decides what to do, and does it. A hybrid of an interpreter and a compiler will
compile the statement into machine code and execute that; the machine code is then discarded, to be
interpreted anew if the line is executed again. Interpreters are commonly the simplest implementations
of the behavior of a language, compared to the other two variants listed here.
Compiled
When code written in a language is compiled, its syntax is transformed into an executable form before
Some compilers compile source code directly into machine code. This is the original mode of
compilation, and languages that are directly and completely transformed to machine-native code in this
Intermediate representations
When code written in a language is compiled to an intermediate representation, that representation can
be optimized or saved for later execution without the need to re-read the source file. When the
representation must then be interpreted or further compiled to execute it. Virtual machines that execute
bytecode directly or transform it further into machine code have blurred the once clear distinction
Code written in a language may be translated into terms of a lower-level language for which native code
compilers are already common. JavaScript and the language C are common targets for such translators.
See CoffeeScript, Chicken Scheme, and Eiffel as examples. Specifically, the generated C and C++ code can
be seen (as generated from the Eiffel language when using the EiffelStudio IDE) in the EIFGENs directory
of any compiled Eiffel project. In Eiffel, the translated process is referred to as transcompiling or
Note that languages are not strictly interpreted languages or compiled languages. Rather,
60 and Fortran have both been interpreted (even though they were more typically compiled). Similarly,
Java shows the difficulty of trying to apply these labels to languages, rather than to implementations;
Java is compiled to bytecode which is then executed by either interpreting (in a Java virtual machine
(JVM)) or compiling (typically with a just-in-time compiler such as HotSpot, again in a JVM). Moreover,
compiling, transcompiling, and interpreting is not strictly limited to only a description of the compiler
A high-level language is any programming language that enables development of a program in a much more
user-friendly programming context and is generally independent of the computer's hardware architecture.
A high-level language has a higher level of abstraction from the computer, and focuses more on the
programming logic rather than the underlying hardware components such as memory addressing and
register utilization.
High-level languages are designed to be used by the human operator or the programmer. They are referred
to as "closer to humans." In other words, their programming style and context is easier to learn and
implement than low-level languages, and the entire code generally focuses on the specific program to be
created.
A high-level language does not require addressing hardware constraints when developing a program.
However, every single program written in a high-level language must be interpreted into machine language
The instructions that tell a computer what to do are written in machine code. Machine code is a series of
Programmers find machine code difficult to learn, program in and debug. As a result, the majority of
programmers write programs in high-level programming languages. These languages are close to natural
language - the spoken and written language of humans. For example, Python uses 'print', ‘if’, 'input' and
'while' statements - all words from the English language - to form instructions. In fact, instructions often
Many types of high-level language exist and are in common use today, including:
• Python
• Java
• C++
• C#
• Visual Basic
• JavaScript
Source code
Source code is the term given to a set of instructions that are written in human readable programming
language. Source code must be translated into machine code before a computer can understand and
execute it.
Low-level languages
Low-level languages are languages that sit close to the computer's instruction set. An instruction set is the
• machine code
Machine code is the set of instructions that a CPU understands directly and can act upon. A program
written in machine code would consist of only 0s and 1s - binary. This is very difficult to write and debug.
Assembly language
Assembly language sits between machine code and high-level language in terms of ease of use. While high-
level languages use statements to form instructions, assembly language uses mnemonics - short
abbreviations. Each mnemonic directly corresponds with a machine code instruction. Here are some
examples of mnemonics:
In assembly language, programmers write programs as a series of mnemonics. Mnemonics are much easier
to understand and debug than machine code, giving programmers a simpler way of directly controlling a
computer.
Both opcode and operand values are ultimately represented in binary. However, values may also be
represented in hexadecimal when programming as this number system can represent larger values in
fewer characters, for example, denary 250 is 11111010 in binary, but only FA in hexadecimal.