Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C Programming Language

C compiler internals


Hai,

    Can I get some docs or links to learn the C compiler internals
from basic to advanced. It must contains good documentation of how
compilers allocates memory to variables.

Bye
Guru Jois

On Sun, 27 May 2007 04:52:52 -0700, Guru Jois wrote:
> Hai,

>     Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.

> Bye
> Guru Jois

There are a lot of different C compilers out there and some of them are
closed source. I don't think the MSVC compiler has a lot of in-depth
documentation on how it works internally.

Take a look at the following link for some information about the GCC
compiler:
http://en.wikibooks.org/wiki/Category:GNU_C_Compiler_Internals

Hope it helps a bit.

Regards,
Jensen

Guru Jois wrote:
>     Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.

Why?

I mean, what problem do you hope to solve with this information?

Compilers allocate memory -- and registers -- to variables in
ways that will make the code faster, or smaller, or the compiler
easier to write, or faster, or smaller; the tradeoffs differ
even between compilers for the same architecture and can often
be controlled by command-line switches; what are you going to
do with the answer?

--
Interpreting Hedgehog
"We did not have time to find out everything we wanted to know."
- James Blish, /A Clash of Cymbals/

"Guru Jois" <guru.j@gmail.com> wrote in message

news:1180266772.109733.266650@z28g2000prd.googlegroups.com...

> Hai,

>    Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.

read books on compiler design maybe, although that has nothing to with C
anymore
Guru Jois wrote:
> Hai,

>     Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.

> Bye
> Guru Jois

Hi guru

How lcc-win32 allocates memory to variables
-------------------------------------------

For lcc-win32 there are several types of variables:
1) File scope variables, that are allocated in the initialized variables
    section of the executable. For example:
        int table[] = {1,2,3,4,5,6};
    Lcc-win32 will reserve space in the data section for six 32 bit
    numbers and initialize that to the binary values given.
    Each object code file (.obj) can contain contributions to this
    segment. The linker combines them all into a single segment.
2) File scope variables without any initial values. For example:
         int table[6];
    Lcc-win32 will reserve space for 6 32 bit numbers in the
    uninitialized variable section (bss) and the value of them will be
    set to zero when the system loads the program into memory.
3) Local variables.
    They are allocated into a memory block reserved for temporary
    storage. This is normally the stack segment. At entry of a function,
    its activation record will be built, and the stack will be adjusted
    to contain space for all local variables of the function. This
    storage will be reclaimed when the function exits.

4) Variable length automatic variables
    This variables will be allocated in the stack in a similar way as
    (3) but they are not part of the activation frame since the
    activation frame is fixed length, and this variables are variable
    length. Example:
    int fn(int n)
    { int table[n]; // <<<--- variable length array (VLA)
    }

Guru Jois wrote:
> Hai,

>     Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.

> Bye
> Guru Jois

Hi guru

How lcc-win32 allocates memory to variables
-------------------------------------------

For lcc-win32 there are several types of variables:
1) File scope variables, that are allocated in the initialized variables
    section of the executable. For example:
        int table[] = {1,2,3,4,5,6};
    Lcc-win32 will reserve space in the data section for six 32 bit
    numbers and initialize that to the binary values given.
    Each object code file (.obj) can contain contributions to this
    segment. The linker combines them all into a single segment.
2) File scope variables without any initial values. For example:
         int table[6];
    Lcc-win32 will reserve space for 6 32 bit numbers in the
    uninitialized variable section (bss) and the value of them will be
    set to zero when the system loads the program into memory.
3) Local variables.
    They are allocated into a memory block reserved for temporary
    storage. This is normally the stack segment. At entry of a function,
    its activation record will be built, and the stack will be adjusted
    to contain space for all local variables of the function. This
    storage will be reclaimed when the function exits.

4) Variable length automatic variables
    This variables will be allocated in the stack in a similar way as
    (3) but they are not part of the activation frame since the
    activation frame is fixed length, and this variables are variable
    length. Example:
    int fn(int n)
    { int table[n]; // <<<--- variable length array (VLA)
    }

Guru Jois wrote:
> Hai,

>     Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.

> Bye
> Guru Jois

Hi guru

How lcc-win32 allocates memory to variables
-------------------------------------------

For lcc-win32 there are several types of variables:
1) File scope variables, that are allocated in the initialized variables
    section of the executable. For example:
        int table[] = {1,2,3,4,5,6};
    Lcc-win32 will reserve space in the data section for six 32 bit
    numbers and initialize that to the binary values given.
    Each object code file (.obj) can contain contributions to this
    segment. The linker combines them all into a single segment.
2) File scope variables without any initial values. For example:
         int table[6];
    Lcc-win32 will reserve space for 6 32 bit numbers in the
    uninitialized variable section (bss) and the value of them will be
    set to zero when the system loads the program into memory.
3) Local variables.
    They are allocated into a memory block reserved for temporary
    storage. This is normally the stack segment. At entry of a function,
    its activation record will be built, and the stack will be adjusted
    to contain space for all local variables of the function. This
    storage will be reclaimed when the function exits.

4) Variable length automatic variables
    This variables will be allocated in the stack in a similar way as
    (3) but they are not part of the activation frame since the
    activation frame is fixed length, and this variables are variable
    length. Example:
    int fn(int n)
    { int table[n]; // <<<--- variable length array (VLA)
    }

There is a bug in the thunderbird client apparently...
It sent the message three times

Sorry about this

jacob

Guru Jois wrote:
> Hai,

>     Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.

Try, comp.compilers and check their FAQ.

--
Tor <torust [at] online [dot] no>

On 27 May 2007 04:52:52 -0700, Guru Jois <guru.j@gmail.com> wrote:

>Hai,

>    Can I get some docs or links to learn the C compiler internals
>from basic to advanced. It must contains good documentation of how
>compilers allocates memory to variables.

Your posts indicate you are a relative newcomer to C and programming.
It is much too early for you to be jumping into a topic this complex.

Why do you care how one particular compiler allocates variables?  It
may have nothing to do with how your compiler does so.  It may change
completely in the next version of the compiler.

At this stage in your development, you should not be writing code that
depends on a particular allocation technique.  Concentrate on the
portable features of the standard language, which is the area this
newsgroup deals with.

Remove del for email

In article <1180266772.109733.266@z28g2000prd.googlegroups.com>,
Guru Jois  <guru.j@gmail.com> wrote:

>Hai,

>    Can I get some docs or links to learn the C compiler internals
>from basic to advanced. It must contains good documentation of how
>compilers allocates memory to variables.

Take a look at the Dragon Book.

If that doesn't tell you what you're looking for, you could always
try Knuth.

dave

--
Dave Vandervies            dj3va@csclub.uwaterloo.ca

Where should I turn in my certificate of infallibility?
                            --CBFalconer in comp.lang.c

"Guru Jois" <guru.j@gmail.com> wrote in message

news:1180266772.109733.266650@z28g2000prd.googlegroups.com...
> Hai,

>    Can I get some docs or links to learn the C compiler internals
> from basic to advanced. It must contains good documentation of how
> compilers allocates memory to variables.

If want the very basics about how to get into the compiler construction
game, read my book MiniBasic - how to write a script interpreter. It is an
interpreted rather than a compiled language, but the principles of variable
usage are similar, however interpreters are easier to write and understand
than compilers. It is only $2.50.

If you already know how to write a Basic, try the dragon book by Aho, Sethi
and Ullman. This is a much more advanced text.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

On May 27, 11:46 pm, Barry Schwarz <schwa@doezl.net> wrote:

Yaeh, I am new to C, but I expect questions about compiler activities
in interviews. So I need docs.
Bye
Guru
In article <1180266772.109733.266@z28g2000prd.googlegroups.com>, Guru
Jois <guru.j@gmail.com> writes

>Hai,

>    Can I get some docs or links to learn the C compiler internals
>from basic to advanced. It must contains good documentation of how
>compilers allocates memory to variables.

Hi,

Compilers are in two parts the front end parser and the target specific
back end. Where the variables are put and how the memory is allocated
will depend on the target which is handled in the back end. It won't be
the same for an 8061 as a 68000 MCU.  Some turn out assembler and some
object code.

I can send you a PDF book on compiler design but no book on compiler
design goes from basic to advanced. They go from advanced to very
advanced.

Then you have the assembler and linker do contend  with

also books on compiler design are standard technology. Most commercial
compilers use many proprietary tricks and techniques.

The best place to start is probably GCC. You get the source and a lot of
people know how it works internally.

I would suggest that the way you  have asked the question indicates that
you probably do not have the experience to delve into compiler design
just yet unless it is just for interest. Though I expect you will find
it very heavy going..
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ c@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

In article <1180340749.681481.98@j4g2000prf.googlegroups.com>, Guru
Jois <guru.j@gmail.com> writes

You will not get questions about compiler internals at interviews. If
you do you are applying for the wrong job.

What sort of jobs are you applying for?

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ c@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

In article <1180340749.681481.98@j4g2000prf.googlegroups.com>, Guru
Jois <guru.j@gmail.com> writes

The missing lines are:-

"I am Master of Computer Application graduate and currently studying
"Advanced C and Unix" course in Uttara, Bangalore, India."

>but I expect questions about compiler activities
>in interviews. So I need docs.
>Bye
>Guru

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills  Staffs  England     /\/\/\/\/
/\/\/ c@phaedsys.org      www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

"Guru Jois" <guru.j@gmail.com> wrote in message

news:1180340749.681481.98780@j4g2000prf.googlegroups.com...

If you want to prepare for an interview have a look through the archived
copy of this newsgroup at  groups.google.com. I would start by searching for
threads that contain "undefined behaviour". Most other documentation
concentrates on "how to do" something. These topics will help you understand
why some things don't work, and also how the compiler works...

I am pretty sure the information in here is more enlightening than any crib
sheet,,,,

"David Wade" <g@yahoo.com> writes:

[...]

> If you want to prepare for an interview have a look through the archived
> copy of this newsgroup at  groups.google.com. I would start by searching for
> threads that contain "undefined behaviour". Most other documentation
> concentrates on "how to do" something. These topics will help you understand
> why some things don't work, and also how the compiler works...

You may need to search for both "undefined behaviour" and "undefined
behavior" (UK vs. US spelling); I'm not sure whether Google is smart
enough to translate automatically.  It's sometimes also referred to as
"UB".

--
Keith Thompson (The_Other_Keith) k@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

In article <lnps4k9229.@nuthaus.mib.org>,
Keith Thompson  <k@mib.org> wrote:

>"David Wade" <g@yahoo.com> writes:
>> If you want to prepare for an interview have a look through the archived
>> copy of this newsgroup at  groups.google.com. I would start by searching for
>> threads that contain "undefined behaviour".
>You may need to search for both "undefined behaviour" and "undefined
>behavior" (UK vs. US spelling); I'm not sure whether Google is smart
>enough to translate automatically.  It's sometimes also referred to as
>"UB".

Search also for nasal and demons (or daemons) ;-)
--
Programming is what happens while you're busy making other plans.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc