Assembler
A assembly language (or assembly language or simply assembler by abuse language , shortened ASM ) is a Low-level language near to the Machine language which can be directly interpreted by the Microprocesseur of the Ordinateur while remaining readable by human.
The assembler was created to facilitate the work of the programmers. It consists in representing the combinations of Bit S employed in binary language by symbols called mnemonic (of the Greek mnêmonikos , relating to the memory), i.e. easy to retain.
For example, a processor of the x86 family recognizes an instruction of the type
10110000 01100001
Into assembly language, this instruction will be represented by an equivalent easier to include/understand for the programmer:
Contrary to a High-level language, there is (except the case of the macros, or macro-instructions) a correspondence one by one between the code assembler and the machine language, thus it is possible to translate the code in the two directions without loss of information. The transformation of the code assembler into machine language is achieved by a program named assembler, in the other direction by a program Désassembleur. The operations are called respectively assembly and dismantling. In a real program out of assembler, it is a little more complex than that (one can give names to the routines, the variables), and one does not have more this correspondence. On the first computers, the task of assembly was manually accomplished by the programmer.
Each Microprocesseur has its own machine language, and thus its own assembly language (the example above is for the X86). These different Microprocesseur has different sizes of registers and an instruction set more or less extended, according to their design and their use.
Moreover, several groups of mnemonic or syntaxes of assembly language can exist for only one whole of instructions, thus creating macro-instructions.
The direction of the transfers
The operands can be reversed.
Let us notice nevertheless that this instruction is translated in the majority of the high-level languages by (here into pseudo-C):
Al = 0x61 ;
translated into syntax Intel by
Also let us notice that in French one would say:
to put 0x61 in Al ;
translated into syntax AT&T by
But in French one also writes: Al receives 0x61 who seems quite as natural. The spoken language thus does not make it possible to justify certain preferences when it is a question of defining the syntax of a computer programming language.
Instructions machine
Basic operations are available in the majority of the instruction sets
- displacement
- loading of a value in a register
- displacement of a value since a site report in a register, and conversely
- calculation
- addition, or subtraction of the values of two registers and loading of the result in a register
- combination of values of two registers according to a Boolean operation (or operation bit with bit)
- modification of the course of the program
- jump on another site in the program (normally, the instructions are carried out sequentially, the ones after the others)
- there jump on another site, but after having safeguarded the following instruction in order to be able to return (not of return)
- return to the last point of return
- comparison
- to compare the values of two registers
And one finds instructions specific with one or some instructions for operations which should have taken much of it. Examples:
- displacement of large memory stacks
- multiplication, division
- arithmetic door (sine, Cosine, square Root, operations on Vector S)
- application of a simple operation (for example, an addition) to a whole of data via the extensions MX or SE of the new processors.
Simple examples
Here some simple examples:- in syntax AT&T (written for the assembler GNU (GAS) for Linux)
- using the instruction set I386
- to be used as follows:
To post Hello
(the comments are after the semicolon)To see the keyboard (16 characters max) then to post it
Directives of the assembly language
In addition to coding the instructions machine, the assembly languages have additional directives to assemble storage blocks and to assign addresses with the instructions by defining labels or labels.
They are able to define expressions symbolic systems which are evaluated with each assembly, making the code even easier to read and to include/understand.
They have usually a language macro integrated to facilitate the generation of codes or complex storage blocks.
Use of the assembly language
There are debates on the utility of the assembly language. In much of case, Compilateur S-optimizers can transform High-level language in a code which turns in a way more effective than a code assembler writes with the hand, while remaining much easier (and less expensive) to write, with reading and " maintenir".
However,
-
some complex calculations written directly out of assembler, in particular on machines massively parallel, will be faster, the compilers not being yet enough advanced to draw part of specificities from these architectures.
- certain routines ( drivers ) are sometimes simpler to write in low-level language.
- of the tasks very dependant on the system, carried out in the memory capacity of the Operating system is sometimes difficult to write in a low-level language.
Certain compilers transform, when their option of the highest optimization is not activated , of the programs written in high-level language in code assembler, each high level instruction being translated into a series of rigorously equivalent instructions assembler and using the same symbols; that makes it possible to see the code from a point of view of debugging and shaping , which makes it possible to save sometimes much more time by altering an algorithm. To in no case these techniques cannot be preserved for final optimization.
The programming of the embarked systems, often containing Microcontrôleur S, is a " niche" traditional for the programming out of assembler. Indeed these systems often are very limited in resources (for example a microcontrolor PEAK 16F84 is limited to 1024 instructions of 14 bits, and its random access memory contains 136 bytes). and thus require programming of low-level very optimized to exploit the possibilities of them. However, the evolution of the material makes that the components of these systems become increasingly powerful at cost and has an electricity consumption constant, the investment in programming " all assembleur" much more expensive in work hours then becomes a nonsense in term of efforts.
Macro-assembler
Many assemblers manage a language of macros. It is a question of gathering several instructions in order to have a more logical sequence and less fastidieux.For example (out of assembler Microsoft MASM):
References
Related article
See Program assembler
Internal bonds
- GNU binutils
- NASM
- FASM
- MASM
- TASM of Borland
External bonds
- complete Course of Assembler courses of Iprezo
- the F.A.Q Assembler answers to your questions about the Assembler
- Tutoriels Assembler
- the forum of mutual aid Assembler
- AsmFR: site of impassioned which shares their knowledge
- NASM - Netwide Assembler
| Random links: | Aeacus | Ludwig Wittgenstein | Dreyse rifle | 1933 with the theater | Willy puchner | Nieuwe Leij |