|win32/linux executables firstname.lastname@example.org (2002-01-03)|
|Re: win32/linux executables email@example.com (Fabrice Medio) (2002-01-05)|
|Re: win32/linux executables firstname.lastname@example.org (Carsten Kuckuk) (2002-01-05)|
|Re: win32/linux executables email@example.com (2002-01-05)|
|Re: win32/linux executables firstname.lastname@example.org (Peter Cooper) (2002-01-05)|
|From:||Fabrice Medio <email@example.com>|
|Date:||5 Jan 2002 01:45:01 -0500|
|Organization:||Wanadoo, l'internet avec France Telecom|
|Posted-Date:||05 Jan 2002 01:45:00 EST|
firstname.lastname@example.org (gods1child) writes:
> Now as a next step towards writing compilers that create binary
> executables, I wanted to write a small compiler. The compiler would
> read an arithmetic expression and create an executable file that would
> accept a number from the console, run it through the compiled
> expression, and output the result to the console. The executable
> should work on win32 (later i want to move to linux too maybe by using
> a common intermediate language that would then be compiled for linux
> and windows).
> where do i start?
These pointers have been extremely precious to me as I wanted to
perform roughly the same task a couple of months ago :
And, obviously, you can give a read at
Unless you want to reinvent hot water, you'll probably have to link
your code to the C library or an equivalent like dietlibc. The key
aspect of linking to foreign code is to understand the argument
passing conventions that are used by the foreign compiler.
By the way, if you're using gcc, beware of poorly documented calling
conventions. Here are a few tricks : arguments are pushed in reverse
order on the stack, and the stack is caller-safe (means the callee
function must give the stack back to the caller in the same state that
it received it). Playing around with gcc -S definitely helps.
Return to the
Search the comp.compilers archives again.