Re: translation from x86 assember to machine code

Joachim Durchholz <joachim_d@gmx.de>
17 Jan 2002 00:27:39 -0500

          From comp.compilers

Related articles
translation from x86 assember to machine code donalies@adelphia.net (michelle) (2002-01-14)
Re: translation from x86 assember to machine code joachim_d@gmx.de (Joachim Durchholz) (2002-01-17)
Re: translation from x86 assember to machine code RLWatkins@CompuServe.Com (R. L. Watkins) (2002-01-17)
Re: translation from x86 assember to machine code hugo_rozas@terra.com.pe (Hugo Rozas M.) (2002-01-17)
Re: translation from x86 assember to machine code rickh@capaccess.org (2002-01-17)
Re: translation from x86 assember to machine code donalies@adelphia.net (michelle) (2002-01-18)
Re: translation from x86 assember to machine code setters@nospam.hotmail.com (Paul Setterfield) (2002-01-28)
| List of all articles for this month |

From: Joachim Durchholz <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 17 Jan 2002 00:27:39 -0500
Organization: Compilers Central
References: 02-01-055
Keywords: assembler, linker
Posted-Date: 17 Jan 2002 00:27:39 EST

michelle wrote:


> I Can Build A Compiler That Outputs Assembly Code,
> But I Don'T Know How To Turn It Into Executable Code.


You need to do things:
1) Generate machine instructions.
2) Wrap the whole stuff with all the information that the operating
system requires to identify the file as executable.


The first task is simple. Just pick up the reference for the target
processor (in the case of x86, just download the references from
intel.com). If you can generate assembly, is should be simple to
replace that backend with a machine code generator, it's just a
different output format.


The second task would be as simple if the executable formats were
well-documented. They have changed massively over the last ten years,
and it's easy to get an outdated reference. (You may want to refer to
our esteemed moderator's book - I forgot the title, it was something
like "Linkers and Loaders".)
General advice: you'll save yourself a lot of fuss and hairpulling if
you simply generate object format, and let the system's linker handle
all the grotty stuff. (Downside: the Windows platform doesn't come with
a linker by default. But digging up an open-source linker will still be
less work than writing yet another one.) (Other downside: most linkers
cannot handle more than C interface conventions. If your language
deviates strongly from C's linkage conventions, the linker may be unable
to handle your requirements.)


HTH
Joachim


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.