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

Assembly Language

Assembly language is a low-level programming language that provides a symbolic representation of machine language instructions, allowing programmers to write more human-readable code while maintaining control over computer operations. It is specific to a processor architecture, making it non-portable, and is advantageous for tasks requiring efficiency and direct hardware manipulation. However, it has limitations such as difficulty in readability, maintenance, and debugging, as well as the necessity for detailed documentation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assembly Language

Assembly language is a low-level programming language that provides a symbolic representation of machine language instructions, allowing programmers to write more human-readable code while maintaining control over computer operations. It is specific to a processor architecture, making it non-portable, and is advantageous for tasks requiring efficiency and direct hardware manipulation. However, it has limitations such as difficulty in readability, maintenance, and debugging, as well as the necessity for detailed documentation.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Assembly language

What is Assembly Language?


Each personal computer has a microprocessor that manages the
computer's arithmetical, logical, and control activities.

Each family of processors has its own set of instructions for


handling various operations such as getting input from keyboard,
displaying information on screen and performing various other jobs.
These set of instructions are called 'machine language instructions'.

A processor understands only machine language instructions,


which are strings of 1's and 0's. However, machine language is too
obscure and complex for using in software development. So, the low-
level assembly language is designed for a specific family of processors
that represents various instructions in symbolic code and a more
understandable form.
Assembly language
Why is ASM useful?
Machine language is just a series of numbers, which is not easy for
humans to read. Using ASM, programmers can write human-
readable programs that correspond almost exactly to machine
language.
The disadvantage is that everything the computer does must be
described explicitly, in precise detail. The advantage is that the
programmer has maximum control over what the computer is
doing.
Why is ASM a "low-level" language?
Assembly is called a low-level programming language because
there is (nearly) a one-to-one relationship between what it tells
the computer to do, and what the computer does. In general, one
line of an assembly program contains a maximum of one
instruction for the computer.
Assembly language
How is ASM different from a "high-level" language?
High-level languages provide abstractions of low-level operations
which allow the programmer to focus more on describing what
they want to do, and less on how it should be done. Programming
this way is more convenient and makes programs easier to read at
the sacrifice of low-level control.
Is ASM portable?
No. Because assembly languages are tied to one specific computer
architecture, they are not portable. A program written in one
assembly language would need to be completely rewritten for it to
run on another type of machine.
Assembly language
Advantages of Assembly Language
Having an understanding of assembly language makes one
aware of −
How programs interface with OS, processor, and BIOS;
How data is represented in memory and other external devices;
How the processor accesses and executes instruction;
How instructions access and process data;
How a program accesses external devices.
Other advantages of using assembly language are −
It requires less memory and execution time;
It allows hardware-specific complex jobs in an easier way;
It is suitable for time-critical jobs;
It is most suitable for writing interrupt service routines and
other memory resident programs.
Assembly language
An assembly language program can be divided into 3 sections:-
The data section
The bss section
The text section
The data Section
The data section is used for declaring initialized data or constants.
This data does not change at runtime. You can declare various
constant values, file names, or buffer size, etc., in this section.
The syntax for declaring data sec on is −
section.data
The bss Section
The bss section is used for declaring variables. The syntax for
declaring bss sec on is −
section.bss
Assembly language
The text section
The text section is used for keeping the actual code. This section
must begin with the declaration global _start, which tells the
kernel where the program execution begins.
The syntax for declaring text sec on is −
section.text global _start _start:
how it works:
Most computers come with a specified set of very basic
instructions that correspond to the basic machine operations that
the computer can perform. For example, a "Load" instruction
causes the processor to move a string of bits from a location in the
processor's memory to a special holding place called a register.
Assembly language
Assuming the processor has at least eight registers, each
numbered, the following instruction would move the value (string
of bits of a certain length) at memory location 3000 into the
holding place called register 8:

L 8,3000

 The programmer can write a program using a sequence of these


assembler instructions.
This sequence of assembler instructions, known as the source
code or source program, is then specified to the assembler
program when that program is started.
The assembler program takes each program statement in the
source program and generates a corresponding bit stream or
pattern (a series of 0's and 1's of a given length).
Assembly language
The output of the assembler program is called the object code or
object program relative to the input source program. The
sequence of 0's and 1's that constitute the object program is
sometimes called machine code.
The object program can then be run (or executed) whenever
desired.

Assembler
An assembler is a program that takes basic computer instructions
and converts them into a pattern of bits that the
computer's processor can use to perform its basic operations.
Some people call these instructions assembler language and
others use the term assembly language.
Assembly language
While assembly languages differ between processor architectures, they often
include similar instructions and operators. Below are some examples of
instructions supported by x86 processors.
• MOV - move data from one location to another
• ADD - add two values
• SUB - subtract a value from another value
• PUSH - push data onto a stack
• POP - pop data from a stack
• JMP - jump to another location
• INT - interrupt a process

the following assembly language can be used to add the numbers 3 and 4:
mov eax, 3 - loads 3 into the register "eax"
mov ebx, 4 - loads 4 into the register "ebx"
add eax, ebx, ecx - adds "eax" and "ebx" and stores the result (7) in "ecx"
Assembly language
limitations of assembly language
• No Symbolic names for memory locations. You need to keep track of the exact
memory location that a piece of data is stored. That is, you must manipulate
memory locations directly.

• Hard to read. Although we've made a few improvements by eliminating hex


code, the command names are not always clear.

• Code is still machine dependent. We haven't really moved that far away from
the machine language - just put psuedo-English labels on it. We still need to
rewrite every piece of code for every machine.

• Hard to maintain and debug. Finding mistakes in machine code is difficult.


Correcting them or adding new features can also be a challenge.
• Code must be heavily documented. It's very difficult (if not impossible) to figure
out what a program does by reading the code. Detailed explanation must be
prepared for future coders (including the original programmer) who need to
modify or use the code.

You might also like