answersLogoWhite

0

What are the cousins of compiler?

Updated: 10/3/2023
User Avatar

Wiki User

13y ago

Best Answer

THE COUSINS OF THE COMPILER ARE

  1. Preprocessor.
  2. Assembler.
  3. Loader and Link-editor.

PREPROCESSOR

A preprocessor is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers. The preprocessor is executed before the actual compilation of code begins, therefore the preprocessor digests all these directives before any code is generated by the statements.

They may perform the following functions

1. Macro processing

2. File Inclusion

3."Rational Preprocessors

4. Language extension

1. Macro processing:

A macro is a rule or pattern that specifies how a certain input sequence (often a sequence of characters) should be mapped to an output sequence (also often a sequence of characters) according to a defined procedure. The mapping process that instantiates (transforms) a macro into a specific output sequence is known as macro expansion.

macro definitions (#define, #undef)To define preprocessor macros we can use #define. Its format is:

#define identifier replacement

When the preprocessor encounters this directive, it replaces any occurrence of identifier in the rest of the code by replacement. This replacement can be an expression, a statement, a block or simply anything. The preprocessor does not understand C++, it simply replaces any occurrence of identifier by replacement. #define TABLE_SIZE 100 int table1[TABLE_SIZE];

int table2[TABLE_SIZE];

After the preprocessor has replaced TABLE_SIZE, the code becomes equivalent to: int table1[100];

int table2[100];

2.File Inclusion:

Preprocessor includes header files into the program text. When the preprocessor finds an #include directive it replaces it by the entire content of the specified file. There are two ways to specify a file to be included:

#include "file"

#include

The only difference between both expressions is the places (directories) where the compiler is going to look for the file. In the first case where the file name is specified between double-quotes, the file is searched first in the same directory that includes the file containing the directive. In case that it is not there, the compiler searches the file in the default directories where it is configured to look for the standard header files.

If the file name is enclosed between angle-brackets <> the file is searched directly where the compiler is configured to look for the standard header files. Therefore, standard header files are usually included in angle-brackets, while other specific header files are included using quotes.

3."Rational Preprocessors:

These processors augment older languages with more modern flow of control and data structuring facilities. For example, such a preprocessor might provide the user with built-in macros for constructs like while-statements or if-statements,where none exist in the programming language itself.

4.Language extension :

These processors attempt to add capabilities to the language by what amounts to built-in macros. For example, the language equal is a database query language embedded in C. Statements begging with ## are taken by the preprocessor to be database access statements unrelated to C and are translated into procedure calls on routines that perform the database access.

The behavior of the compiler with respect to extensions is declared with the #extension directive: #extension extension_name : behavior #extension all : behavior

extension_name is the name of an extension. The token all means that the specified behavior should apply to all extensions supported by the compiler.

ASSEMBLER

Typically a modern assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities. The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications. Most assemblers also include macro facilities for performing textual substitution-e.g., to generate common short sequences of instructions as inline, instead of called subroutines, or even generate entire programs or program suites.

There are two types of assemblers based on how many passes through the source are needed to produce the executable program.

  • One-pass assemblers go through the source code once and assumes that all symbols will be defined before any instruction that references them.
  • Two-pass assemblers create a table with all symbols and their values in the first pass, then use the table in a second pass to generate code. The assembler must at least be able to determine the length of each instruction on the first pass so that the addresses of symbols can be calculated.

The advantage of a one-pass assembler is speed, which is not as important as it once was with advances in computer speed and capabilities. The advantage of the two-pass assembler is that symbols can be defined anywhere in the program source. As a result, the program can be defined in a more logical and meaningful way. This makes two-pass assembler programs easier to read and maintain

LINKERS AND LOADERS

A linker or link editor is a program that takes one or more objects generated by a compiler and combines them into a single executable program.

Three tasks

1. Searches the program to find library routines used by program, e.g. printf(), math routines.

2. Determines the memory locations that code from each module will occupy and relocates its instructions by adjusting absolute references

3. Resolves references among files Loader

A loader is the part of an operating system that is responsible for loading programs, one of the essential stages in the process of starting a program. Loading a program involves reading the contents of executable file, the file containing the program text, into memory, and then carrying out other required preparatory tasks to prepare the executable for running. Once loading is complete, the operating system starts the program by passing control to the loaded program code.

All operating systems that support program loading have loaders, apart from systems where code executes directly from ROM or in the case of highly specialized computer systems that only have a fixed set of specialised programs.

In many operating systems the loader is permanently resident in memories, although some operating systems that support virtual memory may allow the loader to be located in a region of memory that is pageable.

In the case of operating systems that support virtual memory, the loader may not actually copy the contents of executable files into memory, but rather may simply declare to the virtual memory subsystem that there is a mapping between a region of memory allocated to contain the running program's code and the contents of the associated executable file. The virtual memory subsystem is then made aware that pages with that region of memory need to be filled on demand if and when program execution actually hits those areas of unfilled memory. This may mean parts of a program's code are not actually copied into memory until they are actually used, and unused code may never be loaded into memory at all.

Steps for loaders :

- Read executable file's header to determine the size of text and data segments

- Create a new address space for the program

- Copies instructions and data into address space

- Copies arguments passed to the program on the stack

- Initializes the machine registers including the stack ptr

- Jumps to a startup routine that copies the program's arguments from the stack to registers and calls the program's main routine

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

The answer might be interpreters. Both compilers & interpreters translate a higher level language into machine code, but interpreters do it line by line & compilers do the whole program at once. I guess that makes them 'cousins'.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the cousins of compiler?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why you call as cousins of compiler?

"Cousins" of the compiler are those things related to the compiler, and may or may not be part of the compiler. This includes: preprocessors, assemblers, linkers, and interpreters.


What are the cousins of a compiler?

First cousin twice removed is an interpreter, second cousin is an assembler. Its siblings are a text-editor, a linker and a debugger.


How many types of compiler naming in list?

cross compiler . hybird compiler . post compiler. ideal compiler. intelligence compiler.


What is DML Compiler?

What is difference between Compiler and DML Compiler


What are the difference between a compiler design and a compiler?

In Compiler there is no design word ,whereas in compiler design there is design word


What are the responsibilities of a compiler?

What are the responsibities of a compiler


What are the four types of grammars used in compiler?

-Single pass compiler -Multi pass compiler -Cross compiler -Optimizing compiler


It is possible to build a C compiler on top of a C compiler?

It is possible to build a C compiler on top of a C compiler. From the directory, run the shell script.


Whether MS VC is one pass compiler or multi pass compiler?

one pass compiler


What is 16 bit compiler?

Quite simply, a 16-bit compiler is a compiler for a 16-bit machine.


PASCAL compiler is written in which language?

Which Pascal compiler do you mean? Pascal compiler can be written in Pascal, of course.


Are languages and compilers application softwares?

No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.No. A compiler is a system software. An application can be created using a language and a compiler. A language is what you write the software with.