karishma bhasin

Upload: karishmabhasin

Post on 10-Apr-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 karishma bhasin

    1/27

    H IGH LEVEL L ANGUAGESCOMPILER

    INTERPRETERL INKER

    A SSEMBLER

  • 8/8/2019 karishma bhasin

    2/27

    A high-level programming language isan advance programming language withstrong abstraction from the details of the

    computer .

    Examples : BASIC,FORTAN,C,PASCAL A,C++, etc

    H IGH L EVEL L ANGUAGE

  • 8/8/2019 karishma bhasin

    3/27

    ADVANTAGES OF HIGH LEVELLANGUAGES

    Machine independence

    Easy to learn and use

    Fewer errors

    Lower program preparationEasy to maintain

  • 8/8/2019 karishma bhasin

    4/27

    LIMITATIONS OF HIGH LEVELLANGUAGES

    LOWER EFFICIENCY : High level language result inmultiple machine language instructions that may not be optimized,taking more time to execute and requiring more main memory space.

    LESS FLEXIBILITY : High level languages are less flexiblebecause they normally do not have mechanism to control acomputers CPU , memory and registers.

  • 8/8/2019 karishma bhasin

    5/27

    TYPES OF LANGUAGE PROCESSORS

  • 8/8/2019 karishma bhasin

    6/27

    COMPILER

    A compiler is a translator program that

    translates(converts) a high-levellanguage program (source program)into its equivalent machine-languageprogram (object program).

    Examples : FORTR A N COMPILER, COBOLCOMPILER, C COMPILER.. etc.

  • 8/8/2019 karishma bhasin

    7/27

  • 8/8/2019 karishma bhasin

    8/27

    B ASIS OF REQUIREMENT OF A COMPILER

    Compiler for L1

    Compiler for L2

    Program P1 in highlevel language L1

    Program P2 in highlevel language

    L2

    Machine code for P1

    Machine code for P2

  • 8/8/2019 karishma bhasin

    9/27

    T RANSLATION P ROCESSO F A C OMPILER

    COMPILERINPUT OUTPUTHIGH LEVELLANGUAGEPROGRAM

    MACHINELANGUAGEPROGRAM

    (Source Program) (Object Program)One to many correspondence

  • 8/8/2019 karishma bhasin

    10/27

    Executed oncomputer A

    Compiler forlanguage L1

    on computer A

    Compiler forlanguage L1

    on computer BExecuted oncomputer B

    Machine codefor P1 thatwill run oncomputer A

    Machinecode for P1that will runoncomputer B

    Program P1and high-levellanguage L1

    Same resultsobtained

  • 8/8/2019 karishma bhasin

    11/27

    W ORKING OF A C OMPILER

    W hen a source program is to be translated, the compiler and thesource program are copied from secondary storage into the mainmemory of the computer .

    The compiler, being a program is then executed with the sourceprogram as its input data .

    It generates the equivalent object program as its output which isnormally saved in a file on secondary storage .

    W henever there is a need to execute the program the objectprogram is copied from secondary storage in to the mainmemory of the computer and executed .

  • 8/8/2019 karishma bhasin

    12/27

    S ECONDARY F UNCTION O F A C OMPILER

    Compilers also detect and indicate certain typesof errors in source programs, these errors arecalled Syntax Errors.

    Some typical syntax errors-Illegal charactersIllegal combination of characters

    Improper sequencing of instructions in aprogramUse of undefined variable names

  • 8/8/2019 karishma bhasin

    13/27

    RECOMPILATION OF A SOURCE PROGRAM

    START

    Edit source program

    Compile sourceprogram

    Syntaxerrors

    detected?

    Generate list of coded

    error messages

    Generate object

    program

    STOP Y es

    No

    Source program

    Object program

  • 8/8/2019 karishma bhasin

    14/27

    INTERPRETER

    An interpreter is a type of translator that translatesprograms written in high level languages into machine

    language.

    An interpreter takes one statement of the sourceprogram , translates it into machine language

    instructions and then immediately executes the

    resulting machine language instructions before takingthe next statement for translation.

    Examples: Basic interpreter , Java script interpreter

  • 8/8/2019 karishma bhasin

    15/27

    ROLE OF AN INTERPRETER

    High levellanguageprogram(Source

    Program)

    INPUT

    INTERPRETER(translates and

    executes statement-by-statement)

    OUTPUTResult of program

    execution

    There is a need to repeat the interpretation process

    every time you wish to execute the program

  • 8/8/2019 karishma bhasin

    16/27

    A DVANTAGES OF AN I NTERPRETER

    Interpreters are easy to write

    Less complex

    A syntax error in a program statement isdetected and brought to the attention of theprogrammer as soon as the program statement is

    interpreted.

    Require less memory space for execution.

  • 8/8/2019 karishma bhasin

    17/27

    D ISADVANTAGES O F A N I NTERPRETER

    REPEATED INTERPRETATION : Since duringinterpretation ,no object program is saved for future use,repeated interpretation (translation + execution) is

    necessary for its repeated execution.

    SPEED : Interpreters are slow while running a finishedprogram because each statement is translated everytime it is executed from the source program.

  • 8/8/2019 karishma bhasin

    18/27

    B ASIS OFDISTINCTION

    COMPILER INTERPRETER

    OUTPUTThe resulting object program is

    permanently saved for futureuse.

    No object program is savedfor future use.

    REPETITIONRepeated compilation is not

    necessary for repeatedexecution of program.

    Repeated interpretation isnecessary for repeatedexecution of program .

    DETECTION OFS Y NTAX ERROR

    Syntax error is not detectedearly.

    Syntax error is detected assoon as the program

    statement is interpreted.

    CHARACTERISTIC They are complex to write. They are easier to write.

    TIMECONSUMPTION

    It is less time consuming to runa program under the

    compiler as it is faster.

    It is slow while running afinished program.

  • 8/8/2019 karishma bhasin

    19/27

    L INKER

    A Linker or Link Editor is a program that takesone or more object program files generated by

    a compiler and combines them into asingle executable program which is called a loadmodule .

  • 8/8/2019 karishma bhasin

    20/27

    W H Y IS L INKER REQUIRED ?... P ART 1 ADAPTATION OF MODULAR APPROACH : A Modular

    approach is adapted to develop reasonably sized softwarebecause.

    A software often consists of several millions of lines of programcode which cant be stored in a single source program file.

    The large size of the file would make it very difficult to workwith.e.g.it is impossible to load the file for compilation on acomputer with limited main memory capacity.

    It would make it difficult to deploy multiple programmers to workconcurrently towards the development of the software for completingit within a specified time limit.

    Any change in the source program would require the entiresource program to be recompiled.

  • 8/8/2019 karishma bhasin

    21/27

  • 8/8/2019 karishma bhasin

    22/27

    ASSEMBLER

    An Assembler is a utility translator program whichconverts (translates) assembly language program into its

    equivalent machine language program , before it can beexecuted on the computer.

    An Assembler also assembles the machine languageprogram in the main memory of the computer and

    makes it ready for execution.

    Examples: Go A sm,T A SM(Turbo A ssembler Software),M A SM,X86(-64),MIPSetc.

  • 8/8/2019 karishma bhasin

    23/27

  • 8/8/2019 karishma bhasin

    24/27

  • 8/8/2019 karishma bhasin

    25/27

    B ASIS OFDISTINCTION

    ASSEM B LER INTERPRETER

    PRIMARYFUNCTION

    It converts assembly languageprogram into its equivalent

    machine language program.

    It translates high-levellanguage program into its

    equivalent machinelanguage program .

    SECONDARYFUNCTION

    It assembles the machinelanguage program in the mainmemory of the computer andmakes it ready for execution .

    It immediately executesresulting machine language

    instructions

    MEMORY SPACE Require more memory space for execution.

    Doesnt require memoryspace for execution .

    OUTPUT The output given by assembler isthe object program.

    The output given byinterpreter is the result of the program execution .

  • 8/8/2019 karishma bhasin

    26/27

    BRIEF RECAPITULATION

    A Compiler is a translator program which translates a high-level languageprogram (source code) into its equivalent machine-language program (object

    program).

    A n Interpreter is a translator program ,which translates a high-level languageprogram into its equivalent machine-language program .It takes one statement of the source program,translates it into machine-language instructions,and thenimmediately executes the resulting machine language instructions before takingthe next statement for translation.

    A Linker is a program , which takes multiple object programfiles (modules) of a software , and fits them together toassemble them into the programs final executable form.

    A n Assembler is a utility translator program whichconverts (translates) assembly language program into itsequivalent machine language program , before it can beexecuted on the computer.

  • 8/8/2019 karishma bhasin

    27/27

    MADE B Y:

    PALAK AGGARWAL (9956)

    KARISHMA BHASIN (9957)

    DISHA KHANNA (9958)