What is an assembly language

W

An assembly language is a computer programming language that, instead of the machine code, uses a symbolic designation of program elements, relatively easy to read and interpreted by humans. It is used mostly to increase the running speed of programs.

What are the advantages and disadvantages of using an assembly language

Although it is one of the oldest programming languages, the assembly language is also built into the latest compilers such as Visual C ++ and Delphi. The assembly code is very close to the executable code of the programs, the assembler having the role of coding the instructions in assembly language in machine code. Nowadays, assembly language is less and less used in writing programs, because the latest generation compilers have the most used functions of programmers already written and optimized in assembly language (memmove, memset/fillchar, etc.) included in units and libraries.
Of course, if you want to achieve very low execution times, using the assembly language is preferable (when we have the optimal complexity algorithm).

Advantages of the assembly language:
1. Very high execution speed of programs (some written and optimized assembled programs have execution speeds up to 5-10 times higher than those written in C or Pascal);
2. The size of the executable code is very small;
3. Help the user better understand how the microprocessor works and write effective programs in High-Level Languages.

Disadvantages of the assembly language:
1. Not Portable; a written program for IBM PCs will not run on an Apple Macintosh (differs some instructions);
2. An assembly program is harder to write and takes longer than a program written in Pascal or C;
3. A written assembly program is harder to troubleshoot;

Most compilers now allow the programmer to write certain parts of the code or subprograms in assembly so that the programmer can only write the part of the program that runs most of the time, the application running much faster.

There are also compilers dedicated to assembly language, such as TASM – Turbo Assembler (found in the BP / Bin directory), MASM – Microsoft Assembler.

Getting the basics of the assembly language

The assembly language is very close to the executable code, so in order for the programmer to be able to write the assembly code, it needs to know how the microprocessor works and how it executes the instructions. All arithmetic/logic/memory access is done through registers. The microprocessor registers are similar to the variables (they can be initialized with certain values; they can be performed on them, they can be accessed (read/modify).

Microprocessor registers are classified into several categories:

1. General purpose registries: eax, ebx, ecx, edx and their subregisters;
2. Segment registers: cs (segment), ds (segment data), es (extra segment), ss (stack segment) – are used to address memory in the segmented memory model;
3. Registry index: esi, edi (source index, destination index);
4. Special Registries: ebp, esp, ip;

Flags of the microprocessor

Microprocessor flags are similar to boolean variables. With their help, we can find the result of a comparison or if an operation has produced “overflow”, etc. These flags can not be accessed directly as registers, but testing whether a flag is enabled is done through “jump” (see the cmp statement). A programming language is at a “high” level when, before it can be executed, it first has to go through one or more interpreters (compilers, rolling media).

Levels:

1. low level: assembler – interacts almost directly with the processor
2. medium level: the compiler converts C++ and Pascal into machine code.
3. high level: Java; besides the compilation process, it requires JRE.

The higher the level of language, the easier it is to understand the program by a human, and the lower the level of language, the easier it is to understand the software by a computer. This article treats the “basics” of assembly programming, as the name says, is just an introduction. To know how to program the asm, you need to learn a lot more.

About the author

Ilias spiros
By Ilias spiros

Recent Posts

Archives

Categories