First generation computers were programmed in machine language. The second with assembly language. The third and fourth are programmed in high-level language. Those of the quintana generation will be programmed with a language close to natural language.
Therefore, to program a current computer it is necessary to master some high-level language (BASIC, FORTRAN, COBOL, PASCAL...) and using this language as a tool, we will draft programs that solve our problems. In any case, on a specific computer, and even more so on a micro, we cannot use any language, but one of those that our computer has implemented in its Operating System.
The use of high-level languages does not exclude machine language and especially assembler language. These options, at least that of assembly, are sometimes very suitable.
The aim of this article is to explain when and for what the assembly language (ASSEMBLER) and higher languages should be used.
The commands executed or executed directly by a computer are those written in machine language. Machine language commands are known and executed by the CPU Control Unit. These commands stick to the computer and are relatively simple, each representing a single arithmetic operation or normal logic. The machine language is expressed in binary codes by 0 and 1.
Programming in binary is very heavy, leaving aside the other annoyances. Thus symbolic languages were created, first assembly languages and then higher.
Programs written in symbolic language cannot be run directly. Programs written in machine language can only be run directly. The aim of translators is to overcome this objection.
A translator program takes as data the program written in symbolic language and as a result of its execution creates an equivalent program written in machine language. Therefore, the program that we do when we program it in symbolic language cannot be executed directly, since before executing it we must perform a translation process.
That is why we said that on a computer you can not program in any language, because to program in a language you need your alarm clock. The translation programs are written in machine language and are part of the Operating System, that is, users should not program them and constitute one of the main parts of the auxiliary software that incorporates the computer.
The program that automatically translates from programming language to another language that the machine directly understands, machine language, is called translator. In translators different types are distinguished; on the other hand, assemblers, to translate assembly language programs, and on the other hand, compilers and interpreters to translate higher languages.
When the compilers translate a program, they get an equivalent program in machine language (called an object program), being prepared to run that object program (see figure 1).
On the contrary, interpreters do not fully translate the source program, but read it orderly, translate and execute it. Therefore, they do not correspond to the 2nd independent phase (translation and execution), since both are unified (see figure 2).
A compiler or interpreter can be used to translate a high-level language. For BASIC, PASCAL and others cases, both compiler and interpreter are usually offered. When the translator is very complex and long, interpretative implementation is not convenient. And to carry out the program, the interpreter has to be all the time in the momory, taking for him a part too large. Therefore, most complex languages use compilers. That is why there are no interpreters for COBOL or FORTRAN, at least in normal computers.
When there are two options to return, which one to choose?, interpretation or compilation?
Before answering this question, we must analyze the two main differences generated by its use:
So, to answer the previous question, we must differentiate two cases: For the development of a new program, it is ideal to use an interpreter, since the tests generated by the corrections can be done immediately. When the program is tested and works properly, it is best to get an equivalent object program through the compiler and use the object program in all subsequent executions, so the runtime has been lower as it is not necessary to translate.
Therefore, when there are two options for a certain language, the best thing in the development phase is to use the interpreter, but once proven that the program is fine. Using the compiler you will get a program of objects for use in the exploitation phase.
However, it is often not available as the Operating System offers only one. In most microphones only interpreter is offered for the BASIC language. Programs that translate the assembly language are called machihembradores (ASSEMBLY), although similar to compilers. The assemblers, being the corresponding language of origin the assembly language, present a particular characteristic: their translation is very fast when obtaining a single machine order from each spring. Therefore, the translation process is much simpler than that of compilers.
Regardless of the intrinsic differences in the use of one or another type of translators in a given language, each programming language has its own characteristics that limit its use.
Firstly, programming languages could be classified into two types: high-level language and assembly languages are then compared to the characteristics of both types:
For the same reason, programs written in superior language are more understandable and readable than those written in assembly language.
The characteristics of paragraphs a) and b) favor the use of the upper canvases and those of paragraphs c) and d) against. In short, the use of high-level languages generates more universal, easy, reliable and understandable programs, but with slower execution times and with greater memory reception.
Some of the above features will be analyzed with an example. The example presents a program that, once the first thousand prime numbers are calculated, 1000 are written with three different languages: the assembly language, the FORTRAN and the PASCAL (see figure 3). In all three cases, the same algorithm and programming mode (called structured programming) have been followed, implemented in the mini-router called VAX 750.
Tracing the example, program commands written in assembly language are not understood if the VAX 11 computer assembly language is not known. The other two can be understood if FORTAN or PASCAL is known from any computer.
In the assembly language written program, although orders are understood one by one, it is very difficult to fully understand and make some change. In the other two cases, especially PASCAL, the intelligibility of the program is much greater.
In order to give a clearer idea of the characteristics set out in paragraph (c) above, the examples have translated and executed the 3 programs obtaining the results shown in table 1.
Analyzing Table 1 it is observed that using high-level languages are created programs of greater reception and less slowness. Therefore, in this case, the memo part of the programs written in high-level language commands is (approximately) 50% higher than the part corresponding to the assembly language program, reaching 100% for the data. For runtime, the assembly language program is 50% faster than FORTRAN and 100% faster than PASCAL. These measures are quite widespread, although in the case of the adoption of the memori of this example there are too many differences.
In general, it can be said that programs made in high-level language are 50% slower and higher than those made in assembly language.
After seeing and analyzing the above features, the time has come to answer the main question. When to use an assembly language and when a high level?
The answer is now evident. In most cases, high-level languages and assembly language will be used only in the following two cases.
However, when we use high-level language, what language to choose? It is not the subject of this article to answer this question, but the following three characteristics will be taken into account for decision making:
Table 1 compares the speed corresponding to a PASCAL program and the speed corresponding to a FORTRAN program. PASCAL's is 25% slower, but as can be seen in Figure 3, the PASCAL program reads better than FORTRAN's. In addition, the PASCAL compiler performs many more checks, so errors are found earlier reducing test time.
The languages mentioned here are conventional, that is, imperatives; they have not mentioned the functional languages (LISP and the like) and explanatory languages (PROLOG) that currently have a great development.
Nor have the languages developed for specific applications (GPSS statistics, SIMULATE simulation, etc.) been mentioned.
The criteria to consider when selecting the programming language are: