Saturday 13 April 2019

Compiling and Executing High-level Language Programs

Compiling and Executing High-level Language Programs



The compiling process divided in two parts: One is the analysis of
the source program and the synthesis of the object program in the machine language of the specified machine.The analysis phase uses the precise description of the source programming language. A source language is described using lexical rules, syntax rules, and semantic rules.
Lexical rules specify the valid syntactic elements  of the language. In Syntax rules specify the way in
which valid syntactic elements are combined to form the statements of the language. Syntax rules are often described using a notation known as BNF (Backus Naur Form) grammar. Semantic rules assign meanings to valid statements of the language.

The first block is the lexical analyser. It takes successive lines of a program and breaks them into individual lexical items namely, identify , operator delimiter, etc. and attaches a type tag to each of these. Beside this, it constructs a symbol table for each identify and fiends the internal representation of each constant. The symbol table is used later to allocate memory to each variable.

In the second stage of translation is called syntax analysis. In this phase, expressions, declarations, and other statements are identify ed by using the results of lexical analysis. Syntax analysis is done by using techniques based on formal grammar of the programming language. In the semantic analysis phase, the syntactic units recognised by the syntax analyser are processed. An intermediate representation of the final machine language code is produced.
The last phase of translation is code generation, when optimisations to reduce the length of machine language program is carried out. The output of the code generator is a machine level language program for the specify computer. If a subprogram library is used or if some subroutines are separately translated and compiled, a final linking and loading step is needed to produce the complete machine language program in an executable form.
If subroutines were compiled separately, then the address allocation of the resulting machine language instructions would not be final. When all routines are connected and placed together in the main memory, suitable memory addresses are allocated. The linker job is to find the correct main memory locations of the final executable program. The loader then places the executable program in memory at its correct address.

Therefore, the execution of a program written in high level language involves the following steps:

1. Translation of the program resulting in the object program.
2. Linking of the translated program with other object programs needed for execution, thereby resulting in a binary program.
3. Relocation of the program to execute from the specify c memory area allocated to it.
4. Loading of the program in the memory for the purpose of execution.


0 comments:

Post a Comment