Python Written in C?
Larry Bates
larry.bates at websafe.com`
Tue Jul 22 23:40:52 EDT 2008
Grant Edwards wrote:
> On 2008-07-22, Larry Bates <larry.bates at websafe.com`> wrote:
>> Grant Edwards wrote:
>>> On 2008-07-22, Larry Bates <larry.bates at websafe.com`> wrote:
>>>
>>>> You talk about "writing it in assembly language for each MPU
>>>> chip". Actually it is even better than that. We now have
>>>> these modern inventions, called compilers that do that type of
>>>> work for us. They translate high level instructions, not
>>>> into assembler but into machine language.
>>> Actually, all of the compilers I'm familiar with (gcc and a
>>> handful of cross compilers for various microprocessors)
>>> translate from high-level languages (e.g. C, C++) into
>>> assembly, which is then assembled into relocatable object
>>> files, which are then linked/loaded to produce machine
>>> language.
>>>
>> I just learned something I did not know. I was under the
>> impression that they translated directly to machine code
>> without ever actually generating Assembler text files.
>
> There may indeed be compilers that work that way. On Unix
> systems (which is what I work with) compilers have
> traditionally generated assembly language files.
>
>> Seems like a waste to generate the text and turn around run
>> that through the assembler, but what do I know. I guess that
>> way the compiler can have pluggable assembler back-ends.
>
> Since you probably need an assembler anyway, generating
> assembly-language in the compiler prevents you from having to
> duplicate a bunch of object-code-generation code in two places.
>
I'm not sure I understand what you mean here. The code generation phase of the
top level compiler would have to generate assembler mnemonics instead of just
generating machine coded directly. At that point it should be just as easy to
generate machine code, unless you take advantage of macros, or other helpers
provided in the assembly phase.
My "compiler" work was way back on mainframes and the ones I worked with
definitely didn't produce assembler then needed to be run through the assembler.
They created likable objects directly. But that was over 30 years ago!
All this may be a moot point, because assembler is just a mnemonic
representations of machine language anyway.
-Larry
More information about the Python-list
mailing list