Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How does a Turbo C compiler work?

Status
Not open for further replies.

avssunil

Junior Member level 1
Joined
Nov 13, 2006
Messages
19
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,281
Activity points
1,416
I would like to know how the compiler works.I have Turbo C installed in my PC and there are 2 folders in it.
INCLUDE--which has all the header files
LIB---some obj files are present.

I would like to how when compiling a C program,how does the code gets compiled,ie when the compiler encouters the word's like "printf","scanf",etc...how does the execution happen???
 

Re: How compiler works

googling with this keyword "How compiler works", you have about 70 answers
 

Re: How compiler works

It is static compilation. The obect code is inserted into executable during the linking phase.
 

Re: How compiler works

Although you might be able to understand C source code (at least, after reading this book you will be able to),
your computer can't. A computer requires digital, or binary, instructions in what is called machine language.
Before your C program can run on a computer, it must be translated from source code to machine language.
This translation, the second step in program development, is performed by a program called a compiler. The
compiler takes your source code file as input and produces a disk file containing the machine language
instructions that correspond to your source code statements. The machine language instructions created by the
compiler are called object code, and the disk file containing them is called an object file.

Each compiler needs its own command to be used to create the object code. To compile, you typically use the
command to run the compiler followed by the source filename. The following are examples of the commands
issued to compile a source file called RADIUS.C using various DOS/Windows compilers:
Compiler Command
Microsoft C cl radius.c
Borland's Turbo C tcc radius.c
Borland C bcc radius.c
Zortec C ztc radius.c
To compile RADIUS.C on a UNIX machine, use the following command:
cc radius.c
Consult the compiler manual to determine the exact command for your compiler.
If you're using a graphical development environment, compiling is even simpler. In most graphical
environments, you can compile a program listing by selecting the compile icon or selecting something from a
menu. Once the code is compiled, selecting the run icon or selecting something from a menu will execute the
program. You should check your compiler's manuals for specifics on compiling and running a program.
After you compile, you have an object file. If you look at a list of the files in the directory or folder in which
you compiled, you should find a file that has the same name as your source file, but with an .OBJ (rather than a
.C) extension. The .OBJ extension is recognized as an object file and is used by the linker. On UNIX systems,
the compiler creates object files with an extension of .O instead of .OBJ.


Hope u have got it!
 

How compiler works

good explanation..
 

How compiler works

Conceptually the compiler can be viewed as performing a series of separate passes.

In the first pass the source code is macro expanded in the appropriate macro environment.

A series of source to source optimizing transformations are performed to simplify the source tree. Type declarations are used to select specialized, efficient versions of low level functions.

A graph is generated from the source tree. The structure of the graph reflects the flow of control in the tree. The nodes of the graph contain blocks of intermediate code for an abstract machine with byte addressing and an infinite set of registers. Register allocation is performed based on data flow analysis and machine specific rules concerning live ranges across code fragments.

The blocks of intermediate code are translated into a single linear sequence of target machine code through a process of template matching.

Finally the relative branch instructions are "fixed up" to point to the correct locations in the code sequence.

The compiler is in fact much more complex than this model might suggest. Machine specific optimizations, for example, can be included in any of the passes. The distinction between passes is also not as simple as that listed above. However, this description is sufficient to allow the programmer to make optimal use of the compiler.
 

Re: How compiler works

hi

Conceptually the compiler can be viewed as performing a series of separate passes.

In the first pass the source code is macro expanded in the appropriate macro environment.
A series of source to source optimizing transformations are performed to simplify the source tree. Type declarations are used to select specialized, efficient versions of low level functions.
A graph is generated from the source tree. The structure of the graph reflects the flow of control in the tree. The nodes of the graph contain blocks of intermediate code for an abstract machine with byte addressing and an infinite set of registers. Register allocation is performed based on data flow analysis and machine specific rules concerning live ranges across code fragments.
The blocks of intermediate code are translated into a single linear sequence of target machine code through a process of template matching.
Finally the relative branch instructions are "fixed up" to point to the correct locations in the code sequence.
The compiler is in fact much more complex than this model might suggest. Machine specific optimizations, for example, can be included in any of the passes. The distinction between passes is also not as simple as that listed above. However, this description is sufficient to allow the programmer to make optimal use of the compiler.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top