38.docx

Embed Size (px)

Citation preview

  • 7/25/2019 38.docx

    1/3

    Translation Tools

    Preprocessors, Interpreters, Compilers, and Linkers

    After the source code has been written, it needs to be translated into

    machine code, since machine code is the only language the hardware can directly

    execute. All other languages need development tools that generate the

    corresponding machine code the hardware will understand. This mechanism

    usually includes one or some combination of preprocessing, translation, and/or

    interpretation machine code generation techniques. These mechanisms are

    implemented within a wide variety of translating development tools.

    Preprocessing is an optional step that occurs either before the translation or

    interpretation of source code, and whose functionality is commonly implemented by

    a preprocessor.

    The preprocessors role is to organie and restructure the source code to ma!e

    translation or interpretation of this code easier. The preprocessor can be a separate

    entity, or can be integrated within the translation or interpretation unit.

    "any languages convert source code, either directly or after having been

    preprocessed, to target code through the use of a compiler, a program which

    generates some target language, such as machine code, #ava byte code, etc., from

    the source language, such as assembly, $, #ava, etc

    A compiler typically translates all of the source code to a target code at one time.

    As is usually the case in embedded systems, most compilers are located on the

    programmers host machine and generate target code for hardware platforms that

    differ from the platform the compiler is actually running on.

    These compilers are commonly referred to as cross-compilers.

  • 7/25/2019 38.docx

    2/3

    %ome generate machine code while others generate other high&level languages,

    which then require what is produced to be run through at least one more

    compiler.

    %till other compilers generate assembly code, which must be run through an

    assembler.

    After all the compilation on the programmers host machine is completed, the

    remaining target code file is commonly referred to as an object filedepending

    on the programming language used.

    A linker integrates this ob'ect file with any other required system libraries,

    creating executable binary file, either directly onto the boards memory or

    ready to be transferred to the target embedded systems memory by a loader.

    (ne of the fundamental strengths of a translation process is based upon the

    concept of software placement )referred to as ob'ect placement*, the ability to divide

    the software into modules and relocate these modules of code and data anywhere in

    memory.

    This is an especially useful feature in embedded systems, because+

    mbedded designs can contain several different types of physical

    memory

    They typically have a limited amount of memory compared to

    other types of computer systems

    "emory can typically become very fragmented and

    defragmentation functionality is not available out&of&the&box

    or too expensive

    $ertain types of embedded software may need to be executed from a particular

    memory location.

  • 7/25/2019 38.docx

    3/3

    This software placement capability can be supported by the master processor, which

    supplies specialied instructions that can be used to generate -position independent

    code, it could be separated by the software translation tools alone.

    here a compiler/assembler produces relocatable modules, process instructionformats, and may do some translation of relative to physical )absolute*

    addresses. An interpreter generates )interprets* machine code one source code

    line at a time from source code or target code generated by a intermediate

    compiler on the host system

    An embedded developer can ma!e a big impact in terms of selecting translation

    tools for a pro'ect by understanding how the compiler wor!s and, if there are

    options, by selecting the strongest possible compiler.

    This is because the compiler, in large part, determines the sie of the executable

    code by how well it translates the code. This not only means selecting a

    compiler based on support of the master processor, particular system

    software, and the remaining toolset )a compiler can be acquired separately, as

    part of a starter !it from a hardware vendor, andor integrated within an 01*. 0t

    also means selecting a compiler based upon a feature set that optimies the

    codes simplicity, speed, and sie.

    (ptimiing the code for performance means that the compiler understands and

    ma!es use of the various features of a particular 0%A, such as math operations,

    the register set, !nowing the various types of on&chip 2(" and 2A", the

    number of cloc! cycles for various types of accesses, etc. 3y understanding

    how the compiler translates the code, a developer can recognie what support is

    provided by the compiler and learn.