OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 2:59 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Creating EXE files in VC++
PostPosted: Wed Mar 05, 2003 6:39 pm 
Hi there,

I would like to develop a compiler in win32 environment using VC++. Is there any way, i'll b able to generate executable code in VC++. Like i would want my program to create exe files on the fly, like vc++ or vb or any other programming language.

thnx in advance,
R Karthick


Top
  
 
 Post subject: Re:Creating EXE files in VC++
PostPosted: Thu Mar 06, 2003 11:22 am 
Of course. Visual C++ is a superset of C++, which is a superset of C; and C has been used to write a large number of compilers over the years, including the VC++ compiler. QED.

Actually, it should be possible to write a compiler, at least a simple one, in any language that can write binary data to a file (or something that can be readily converted to it, such as the old Intel HEX format). Compilers and assemblers have been written in COBOL, Fortran, Pascal, Prolog, VB, and, in one truly perverse case (the original implementation of Orthogonal), INTERCAL. While writing one that also handles linking (or which doesn't need a linker, i.e., does not allow external code references) is harder, it is not infeasible.

However, I would be interested in knowing what the application is. Is the compiler itself the final goal, or is it part of a larger program? If the latter, why wouldn't an interpreter (which generally speaking is far easier to write and debug) do as well? Do you intend to write it portable C++, or do you need to use VC++ specific extensions? Do you mean to write a retargetable code generator, and if so, would it make sense to target a simpler CPU or p-machine (say, the JVM) first before trying to generate x86 code? What kind of language do you mean to implement? Or is the goal something else entirely (automatic program generation, genetic algorithms, etc.)?


Top
  
 
 Post subject: Re:Creating EXE files in VC++
PostPosted: Thu Mar 06, 2003 7:13 pm 
I think I just answered your question in comp.os.ms-windows.programmer.win32 :).

Anyway, here's my response:
I recommend that you write your compiler to emit assembly code files. You can then assemble them using an assembler (e.g. NASM or Microsoft MASM) to create .OBJ files, which you can link with a linker. Later, you can start emitting .OBJ files directly by emitting machine code instead of text assembly code.


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 142 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group