RSS
Логотип
Баннер в шапке 1
Баннер в шапке 2
2010/05/19 13:39:56

Assembler language

Language of the assembler  (autocode)  — a programming language of the low level. Unlike language of machine codes, allows to use mnemonic (character) designations of commands, more convenient for the person. At the same time the translation from assembler language in the machine code understood by the processor requires the special program called by the assembler.

Content

Maintenance of language

Assembler one language commands to one correspond to commands of the processor, actually, they represent a character form of record (mnemonic code) of commands, more convenient for the person, and their arguments.

Besides, language of the assembler provides use of symbolical tags instead of memory cell addresses which when assembling are replaced with automatically calculated absolute or differential addresses and also so-called directives (the commands which are not transferred to processor instructions, and executed by the assembler).

Directives of the assembler allow to include, in particular, data units, to set assembling of a fragment of the program for a condition, to set values of tags, to use macro definitions with parameters.

Each model (or family) processors has the command set and the assembler language corresponding to it. The most popular syntaxes: Intel syntax and AT&T-синтаксис.

There are computers implementing as machine a programming language of the high level (Forth, Lisp, Ale-76), actually in them it is "assembler".

Merits and demerits

Advantages

Shortcomings

Application

It is historically possible to consider the assembler as the second generation of the computer programming languages (if the first to consider machine code). Assembler shortcomings, complexity of development on it big software packages led to emergence of languages of third generation  — programming languages of the high level (A Fortran, Lisp, Kobol, Pascal, Si, etc.). Programming languages of the high level and their successors are generally used in the information technology industry now. However, languages of the assembler save the niche caused by their unique advantages regarding efficiency and a possibility of complete use of specific means of the specific platform.

On the assembler programs or fragments of programs for which are crucial are written:

  • high-speed performance (drivers, games);
  • the volume of the used memory (the boot sectors, built in (привет) the software, programs for microcontrollers and processors with limited resources, viruses, program protection).

Using programming on the assembler are made:

  • Optimization of sections of the programs, critical to speed, written in language of the high level, such as C ++. It is especially relevant for game consoles which have a fixed performance, and for multimedia codecs which aim to do less resource-intensive and more popular.
  • Creation of the operating systems (OS). OS often write to Si, language which was specially created for writing of one of the first versions of Unix. Hardware dependent code locations, such as OS loader, abstraction level from the hardware  — HAL and a core, are often written on the assembler. It is not enough assembler code in kernels of Windows or Linux as authors aim at portability and reliability, but nevertheless it is present. Some amateur OS, such as MenuetOS, are entirely written on the assembler. At this MenuetOS is located on a diskette and contains a graphical multiwindow interface.
  • Programming of microcontrollers (MK) and other built-in processors. According to professor Tannenbaum, development of MK repeats historical development of computers of the latest time. [1] Today very often apply the assembler to programming of MK. It is necessary to move separate bytes and bits between different storage cells to MK. Programming of MK is very important as, according to Tannenbaum, the car and the apartment of the modern civilized person on average contains 50 [2]
  • Creation drivers. Some sections of drivers interacting with the hardware are programmed on the assembler. Though in general now drivers try to write in languages of the high level in connection with increased requirements to reliability. Reliability for drivers plays a special role as in Windows NT and Linux drivers work in a kernel mode. One error can lead to system crash.
  • Creation of antiviruses and other protective programs.
  • Writing of translators of programming languages.

Illegal field of activity

Programming in language of the assembler is characteristic also of illegal fields of activity in IT, in particular, using the assembler are made:

Binding of programs in different languages

As on the assembler only fragments of programs are often developed, they need to be connected with the other parts of program system written in other programming languages.

It is reached by 2 main methods:

  • At a compilation stage  — an insert in the program of assembly fragments (привет) using special directives of language (in particular, this method is supported by the Si programming language), including writing of functions in assembler language. The method is convenient for simple data translations, but full-fledged assembler code, with data and subprogrammes, including subprogrammes with a set of the inputs and exits which are not supported by high-level languages, using it it is impossible to make.
  • At a configuration stage, or separate compilation. For interaction of the grouped modules it is enough that the binding functions (defined in some modules and which are used in others) supported the necessary agreements of a call (Шаблон:By lang-en) and data types. Separate modules can be written in any languages including on the assembler.

Syntax

The language syntax of the assembler is defined by command system of the specific processor.

Command set

Typical commands of language of the assembler are (the majority of examples are given for Intel syntax of architecture of x86):

  • Commands of transfer of data (mov, lea  , etc.)
  • Arifmeticheky commands (add, sub, imul  , etc.)
  • Logical and bit-by-bit actions (or, and, xor, shr  , etc.)
  • Control instructions course of program execution (jmp, loop, ret  , etc.)
  • Commands of a call of interruptions (sometimes carry to control instructions): int, into
  • Input-output commands to ports (in, out)
  • Also the commands executing check and branch on condition, for example are characteristic of microcontrollers and microcomputers:

* cbne  — to pass if it is not equal
* dbnz  — to decrement and if result nonzero, then to pass
* cfsneq  — to compare and if it is not equal, to pass the following command

Instructions

Typical record format of commands: <source lang="asm">[метка:] опкод [операнды] [;комментарий]</source><source lang="asm">[tag:] opkod [operands] [; comment]</source>

where opkod (activity code)  — directly instruction mnemonic to the processor. Prefixes can be added to it (repetitions, changes of type of addressing and so forth).

Constants, the addresses of registers, core memory addresses and the ave. can act as operands. Differences between standards of Intel and AT&T concern, generally an order of transfer of operands and their syntax at different methods of addressing.

Used mnemonic are usually identical to all processors of one architecture or family of architecture (among widely known  — mnemonic of processors and controllers x86 ARM SPARC PowerPC M68k). They are described in the specification of processors. Possible exceptions:

  • If the assembler uses cross-platform AT&T-синтаксис (original mnemonic are resulted in syntax AT&T)
  • If initially there were two standards of record a mnemonik (the command system was inherited from the processor of other producer).

For example, the Zilog Z80 processor inherited Intel i8080 command system, expanded it and changed mnemonic (and designations of registers) after the own fashion. Motorola Fireball processors inherited Z80 command system, having cut down several it. At the same time, Motorola officially returned to mnemonik of Intel. And at present a half of assemblers for Fireball works with intelovsky mnemonik, and a half with mnemonik of Zilog.

Directives

The program on the assembler may contain directives: the instructions which are not transferred directly to machine instructions, and managing directors of work of the compiler. Set and their syntax considerably differ and depend not on a hardware platform, and on the used translator (generating dialects of languages within one family of architecture). As "a gentleman's set" of directives it is possible to select the following:

  • data definition (constants and variables)
  • management of the program of the organization in memory and parameters of the output file
  • compiler operation mode task
  • various abstractions (i.e. elements of languages of the high level)  — from execution of procedures and functions (for simplification of implementation of a paradigm of procedural programming) before conditional constructions and cycles (for a paradigm of structured programming)
  • macroes

Sample program

Sample programs Hello, world! for different platforms and different dialects: Шаблон:Hider hiding

Шаблон:Hider hiding

Шаблон:Hider hiding

Шаблон:Hider hiding

Шаблон:Hider hiding

Шаблон:Hider hiding

Origin and criticism of the term "assembler language"

This type of languages received the name from the name of the translator (compiler) from these languages  — the assembler (привет  — the collector). The name is caused by the fact that the program "automatically gathered", but was not entered manually pokomandno directly in codes. At the same time the confusion of terms is observed: the assembler quite often call not only the translator, but also the corresponding programming language ("the program on the assembler").

Use of the term "assembler language" can also cause wrong opinion on existence of a certain uniform language of the low level, or at least standards on such languages. When naming language of the assembler it is desirable to specify, the assembler for what architecture means.

In the USSR assembler language called "autocode" earlier.

Notes

  1. Andrew Tannenbaum. Computer architecture. the 5th prod.
  2. microcontrollers.E. Tannenbaum. Computer architecture. the 3rd prod.
  3. Chris Kasperski. Disassembling art

See Also

Links

  • WASM.ru  is the portal devoted to information security and programming in assembler languages.

Literature