6 what does a compiler do when it encounters data

This preview shows page 4 - 6 out of 7 pages.

6. What does a compiler do when it encounters data declarations in a source code file? Data (manipulation) operations? Control structures? When a data declaration is encountered the compiler allocates storage to it and records its name, type, length, and memory address in the symbol table. When data manipulation operations are encountered the compiler generates code to implement the manipulation and code to move data among memory locations and registers as required. Control structures are translated into combinations of condition evaluation and branching instructions. 7. Compare and contrast the execution of compiled programs to interpreted programs in terms of CPU and memory utilization. A compiled (and linked) program consists exclusively of machine instructions. While executing, the program has control of the hardware and only the instructions within the program (or those executed as result of operating system service requests) are actually executed. The contents of memory area are limited to the executing program and whatever system software may be present. The execution of an interpreted program requires that the interpreter itself be present in memory. Statements of the program source code are read, translated, and executed in an iterative fashion. Thus the execution of each program statement requires the execution of both its corresponding machine instructions and the instructions necessary to translate it into those machine instructions. Thus, executing an interpreted program requires more CPU cycles than executing an equivalent compiled program. In addition, more memory is generally required during execution due to the presence (in memory) of the interpreter and all or part of its run-time library. 8. What is link editor? What is a library? How and why are they useful in program development? A link editor is a program that converts object code into executable code. It does this by searching objectcode for unresolved references to subroutines, finding those subroutines within one or more libraries, andcombining the object code and library subroutines into a consistent set of executable code. A library is a stored set of previously defined subroutines. Each subroutine is stored as object code, ready to be linked with other object code.
Image of page 4

Subscribe to view the full document.

The advantage of using linking and library subroutines is simplicity in program compilation and flexibility in the generation of executable code. Complex and/or hardware dependent subroutines can be stored in a library and linked into any set of object code that requires them. This reduces the complexity of the compiler's translation effort. It also allows some portability of application programs through the use of libraries specific to various hardware and system software environments.
Image of page 5
Image of page 6

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern