Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   C Compilation.. (http://www.velocityreviews.com/forums/t631960-c-compilation.html)

raashid bhatt 08-23-2008 08:13 AM

C Compilation..
 
is there any standards that tell us how c code has to be compiled into
machine code

Antoninus Twink 08-23-2008 08:25 AM

Re: C Compilation..
 
On 23 Aug 2008 at 8:13, raashid bhatt wrote:
> is there any standards that tell us how c code has to be compiled into
> machine code


Yes. Most processor vendors will provide extensive documentation with
advice and guidelines for writers of optimizing compilers. For example,
Intel provides all this for free on the web:
http://www.intel.com/products/processor/manuals/


raashid bhatt 08-23-2008 08:33 AM

Re: C Compilation..
 
> No. C code need not even *be* compiled into a particular machine's machine
> code. Often it is not - it is compiled (translated) into a particular
> machine's assembly language instead. It could even be compiled into some
> completely different language.


yes i agree , and C is perhaps a Compiled language. But when people
say C code is faster than any language but i will not be true if we
use diffrent compilers(as u said there is not standard of compiled
code)

Antoninus Twink 08-23-2008 10:02 AM

Re: C Compilation..
 
On 23 Aug 2008 at 9:59, Richard Heathfield wrote:
> - any performance problems are more likely to be a consequence of the
> solution (i.e. your program isn't written as efficiently as it might
> be) than of the translation.


You'd know /all/ about that.

> In any case, correctness is far more important than speed.


False dichotomy. You seem to take the foolish approach that speed
doesn't matter at all, and choosing an O(n^2) algorithm when an O(n)
algorithm is available and in fact simpler and clearer doesn't bother
you in the least. Why? Because you've turned "portability" into an
obsession, and nothing else matters.


Richard Tobin 08-23-2008 11:43 AM

Re: C Compilation..
 
In article <866dncAJS_OtVDLVnZ2dnUVZ8gydnZ2d@bt.com>,
Richard Heathfield <rjh@see.sig.invalid> wrote:

>> is there any standards that tell us how c code has to be compiled into
>> machine code


>No.


Yes, several in fact..

The C standard doesn't say anything about it, but other standards
specify the conventions for procedure call, linking to external
variables, and so on, for many of the operating systems that C is used
on. If you're writing a C compiler that's going to be widely used,
you probably need to follow these standards.

-- Richard
--
Please remember to mention me / in tapes you leave behind.

jacob navia 08-23-2008 01:54 PM

Re: C Compilation..
 
raashid bhatt wrote:
> is there any standards that tell us how c code has to be compiled into
> machine code


In most operating systems, the compiler that compiles the operating
system is the one that decides how the format layout, interface
specifications, etc are to be done.

Under Microsoft windows, it is Microsoft's compiler that specifies
implicitely how things should be done.


This is documented in:

Microsoft Portable Executable and Common Object File Format Specification

Microsoft Corporation
Revision 6.0 - February 1999

In that document are the full specifications for object files,
executable files, and library formats.

What the interface specifications is concerned (parameter passing,
register a&ssignments, etc) those are specified in several pages
mostly in the DDK (Driver Development Kit).

Agner Fog (www.agner.org) wrote a document that makes the big
tour of many different compilers in windows and shows the differences
between them.

The Linux world runs under the gcc evil empire, since it is gcc
that compiles the linux kernel. The specification is called:

SYSTEM V. APPLICATION BINARY INTERFACE.
Intel386 Architecture Processor Supplement. Fourth Edition

For 64 bit Linux you have:

System V Application Binary Interface.
AMD64 Architecture Processor Supplement. Draft Version 0.92, 2004.
18.2 ABIs.

Obviously there are many operating systems, and I can't tell you
about all of them.

An interesting one is AIX, the IBM Unix version. Documentation for
the calling conventions and register assignments is difficult to find,
but there is a good document called:

The Power PC Compiler Writer’s Guide
Edited by:
Steve Hoxey Faraydon Karim Bill Hay Hank Warren

This spells you the essential details for making a correct
program under this processor/OS.



--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32

jacob navia 08-23-2008 01:55 PM

Re: C Compilation..
 
Richard Heathfield wrote:
> Richard Tobin said:
>
>> In article <866dncAJS_OtVDLVnZ2dnUVZ8gydnZ2d@bt.com>,
>> Richard Heathfield <rjh@see.sig.invalid> wrote:
>>
>>>> is there any standards that tell us how c code has to be compiled into
>>>> machine code
>>> No.

>> Yes, several in fact..

>
> Oh, I'm sorry. Perhaps you could enlighten us with some references?
>


I gave many references in my reply to the OP.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32

Kenny McCormack 08-23-2008 02:12 PM

Re: C Compilation..
 
In article <slrngavo0t.tau.nospam@nospam.invalid>,
Antoninus Twink <nospam@nospam.invalid> wrote:
>On 23 Aug 2008 at 9:59, Richard Heathfield wrote:
>> - any performance problems are more likely to be a consequence of the
>> solution (i.e. your program isn't written as efficiently as it might
>> be) than of the translation.

>
>You'd know /all/ about that.
>
>> In any case, correctness is far more important than speed.

>
>False dichotomy. You seem to take the foolish approach that speed
>doesn't matter at all, and choosing an O(n^2) algorithm when an O(n)
>algorithm is available and in fact simpler and clearer doesn't bother
>you in the least. Why? Because you've turned "portability" into an
>obsession, and nothing else matters.


Yes. I think that whatever you may think of Heathfield's ideas and
posting style, even the most die-hard sycophants will have to admit that
he really put his foot in it this time.

You simply have to realize that in the real world, customers pay the
bills *and* customers don't give a darn about "how ya did it". They
care that it works and works well. No real world customer is going to
prefer a "100% portable" solution that is so slow that, for all
practical purposes, it can be said to simply not work. Nor is any real
world customer going to answer in anything other than the obvious way
when asked "So, Mr. Customer who is paying my bills, I can make this
code run faster - making you look better to your bosses - but at the
cost of making it not quite so aesthetically pleasing to the denizens of
this Usenet newsgroup called (amazingly enough) 'comp.lang.c'. Whaddya
think? Should I do it?"

Mind you, all of the above is spoken as one who really does take pride
in my work, likes to make my code aesthetically pleasing, and is
actually somewhat miffed to find that my customers really don't give a
darn about "how ya did it". But that's reality - a domain in which few
clc regulars have had to function in, in decades.

Maybe AT should re-post his little dialog between CBF and his
hypothetical customer. Was quite illuminating.


Joachim Schmitz 08-23-2008 02:25 PM

Re: C Compilation..
 
Richard Heathfield wrote:
> Richard Tobin said:
>
>> In article <866dncAJS_OtVDLVnZ2dnUVZ8gydnZ2d@bt.com>,
>> Richard Heathfield <rjh@see.sig.invalid> wrote:
>>
>>>> is there any standards that tell us how c code has to be compiled
>>>> into machine code

>>
>>> No.

>>
>> Yes, several in fact..

>
> Oh, I'm sorry. Perhaps you could enlighten us with some references?


Start with:
http://en.wikipedia.org/wiki/Applica...nary_interface

However, none if this would be topical in comp.lang.c...

Bye, Jojo



Richard Tobin 08-23-2008 03:30 PM

Re: C Compilation..
 
In article <lp6dnbldj6wWQzLVnZ2dneKdnZydnZ2d@bt.com>,
Richard Heathfield <rjh@see.sig.invalid> wrote:

>In any case, correctness is far more important than speed.


Not always. For some purposes, as someone used to have in their
signature, "late answers are wrong answers".

-- Richard
--
Please remember to mention me / in tapes you leave behind.


All times are GMT. The time now is 07:26 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57