In order for the machine to be able to execute human commands at the hardware level, it is necessary to set a certain sequence of actions in the language of “zeros and ones”. Assistant in this matter will be Assembler. This is a utility that works with translating commands into machine language. However, writing a program is a very laborious and complex process. This language is not intended to create easy and simple actions. At the moment, any programming language used (Assembler works fine) allows you to write special effective tasks that greatly affect the operation of the hardware. The main purpose is to create microcommands and small codes. This language provides more features than, for example, Pascal or C.
Short Description of Assembler Languages
All programming languages are divided into levels: low and high. Any of the syntactic system of the "family" of Assembler is different in that it combines at once some of the advantages of the most common and modern languages. They are also related to others by the fact that you can fully use the computer system.
A distinctive feature of the compiler is ease of use. In this, he differs from those that work only with high levels. If you take into account any such programming language, Assembler functions twice as fast and better. It will not take too much time to write an easy program in it.
Briefly about the structure of the language
Speaking generally about the work and structure of the functioning of the language, we can say for sure that its commands are fully consistent with the processor's commands. That is, Assembler uses mnemonic codes that are most convenient for a person to record.
Unlike other programming languages, Assembler uses specific labels instead of addresses to write memory cells. They are translated into the so-called directives with the process of code execution. These are relative addresses that do not affect the processor (are not translated into machine language), but are necessary for recognition by the programming environment itself.
Each processor line has its own command system. In this situation, any process will be correct, including translated machine code.
The assembly language has several syntaxes that will be discussed in the article.
Language pluses
The most important and convenient adaptation of the Assembler language will be that you can write any program for the processor on it, which will be very compact. If the code turns out to be huge, then the programming environment redirects some processes to RAM. At the same time, they all perform quite quickly and without failures, unless, of course, they are controlled by a qualified programmer.
Drivers, operating systems, BIOS, compilers, interpreters, etc., are all assembler-based programs.
When using a disassembler that translates from machine to computer language, you can easily understand how a particular system task works, even if there is no explanation for it. However, this is only possible if the programs are light. Unfortunately, it’s quite difficult to understand non-trivial codes.
Language cons
Unfortunately, novice programmers (and often professionals) find it difficult to make out the language. Assembler requires a detailed description of the necessary command. Due to the fact that you need to use machine instructions, the likelihood of erroneous actions and the complexity of execution increases.
In order to write even the simplest program, a programmer must be qualified, and his level of knowledge is quite high. The average person, unfortunately, often writes bad codes.
If the platform for which the program is being created is updated, then all the commands must be rewritten manually - this is required by the language itself. Assembler does not support the function of automatic regulation of the process performance and replacement of any elements.
Language Commands
As mentioned above, each processor has its own set of instructions. The simplest elements that can be recognized by any type are the following codes:
- Data is transferred using mov, etc.
- Arithmetic related teams: sub, imul, etc.
- Bitwise and logical functions can be implemented using or, and, etc. These are the basics of the Assembler language that allow it to be similar to others.
- In order to make the transition from one command to another, the following operators should be written: djnz, cfsneq, cjne. To an inexperienced programmer it may seem that this is just a set of letters, but this is not true.
- In and out apply if there is a need for input to the port (or output from it).
- Control commands include int. Thanks to him, you can stop the execution of any processes in favor of the main action.
Using Directives
The programming of microcontrollers in the language (Assembler allows this and perfectly copes with the functioning) of the lowest level in most cases ends successfully. It is best to use processors with limited resources. For 32-bit technology, this language fits perfectly. Often in codes you can see directives. What is this? And what is it used for?
First you need to focus on the fact that directives are not translated into machine language. They govern the compiler to do the work. Unlike commands, these parameters, having various functions, differ not due to different processors, but due to another translator. Among the main directives are the following:
- Well-known macros.
- There are also directives possessed by a higher language. The assembler perfectly reads and executes them.
- Functions for monitoring and controlling compiler modes.
- Recognition of constants and variables.
- Regulation of the work of programs that are in RAM.
origin of name
What is the name of the language - "Assembler"? We are talking about a translator and compiler, which encrypt the data. From English, Assembler means nothing but a collector. The program was not compiled manually; an automatic structure was used. Moreover, at the moment, the difference between the terms has already been erased by users and specialists. Often assembly languages are called programming languages, although this is just a utility.
Due to the generally accepted collective name, some have the erroneous decision that there is a single low-level language (or standard standards for it). In order for the programmer to understand what kind of structure is involved, it is necessary to specify for which platform this or that assembler language is used.
Macro tools
Assembler languages, which were created relatively recently, have macro tools. They facilitate both writing and executing the program. Due to their presence, the translator executes the written code many times faster. When creating a conditional selection, you can write a huge block of commands, but it’s easier to use macro tools. They will allow you to quickly switch between actions if the condition is met or not fulfilled.
When using macro language directives, the programmer receives Assembler macros. Sometimes it can be widely used, and sometimes its functional features are reduced to a single command. Their presence in the code facilitates the work with it, makes it more understandable and visual. However, you should still be careful - in some cases, macros, on the contrary, worsen the situation.