Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Hi!
It's my first question on CodeProject (I left Stackoverflow).
I've been thinking about making my own programming language for Windows but I don't even know what the exe files actually are(!). Sometime ago, somebody told me that they are binary, but that for sure is wrong, because the same exe files don't run on another OS. And there is different binary for different processors, but the same exe files run of multiple processors. These are my questions:

Are Windows exe files written in assembly? If no, then in what language?

From where can I learn the language in which exe files are written?

If someone can help me with these, I'd really appreciate their help.
Posted
Comments
Michael_Davies 26-Jul-15 5:49am    
Try Google.

http://www.fileformat.info/format/exe/corion-mz.htm
[no name] 26-Jul-15 7:32am    
You are confusing the programming language "Assembly", with the .NET notion of an assembly to refer to exe and DLL files. They have nothing to do with each other.

There's actually no single type for an EXE other than it (most often) is an executable file. The actual type of the program is defined in the header in the file. It can be a directly executable file which I believe you mean with binary or it can be a file that is some intermediate language such as MSIL which is interpreted at the run time.

Have a look at:
- .exe[^]
- MSIL[^]

About the language to wrote programs, there are many. Languages like C or even Assembler have been used for a long time to write programs. These days there's much more variety in languages to choose from like C#, Java and so on. Using an Assembler or a C compiler source code from those languages would have often been compiled to a native (from the OS point of view), binary exe whereas code written in C# results to an interpretative code by the compiler.
 
Share this answer
 
Yes, exe files (like all files) are binary. However, the structure of the binary content is in a special format that the Windows OS can read and load into memory to be run. Google will find you papers that explain the structire of intermediate .obj files, which are created from source code. Also .exe files which are created from .obj and .lib files to make the final executable. If you are planning to invent a new language then you also need to understand how compilers turn source language into relocatable object code.
 
Share this answer
 
Comments
enhzflep 27-Jul-15 0:17am    
No-one else mentioned relocation - an important point.
My 5.
Richard MacCutchan 27-Jul-15 4:05am    
Thanks. It's amazing what you remember when you start to think about some of these questions.
enhzflep 27-Jul-15 23:57pm    
:Laughs:
Yeah, I've still got part's of Ralph Brown's x86 interrupt list locked away in the memory banks. I don't recall using any of it since about 97 or so. :)
Windows exes are written in a range of languages: if it compiles to an EXE file, it's been used.
So...assembler, C, C++, C#, VB, Pascal, Fortran, Cobol, BrainF*ck, and probably a couple of dozen others have been used. Even Windows itself is written in C, C++, C#. Some parts probably still in assembler!

Learn a language. Get skilled in it. I'd suggest you start in C# myself, but there are those who will suggest VB, or C++. No-one will suggest you start with assembler these days!

So get a book - Addison Wesley and Wrox do good ones - or go on a course. Don;t try to learn by picking it up as you go, you will miss too many important things. Get a copy of Visual Studio from Microsoft - they do free editions - and follow the course or book from beginning to end, doing all the exercises.
 
Share this answer
 
Comments
Nafees Hassan 26-Jul-15 5:34am    
Thanks, but that's not what I asked in the question. I am an experienced programmer (I know Delphi, C++, C#, PHP, and a lot more). I asked that: I need to create a compiler, and for that I need to know what exe files are written in (like a *.pas file means that the file is written in pascal)
enhzflep 26-Jul-15 7:21am    
There are 4 question-marks in your original post. They immediately follow the text
Are Windows exe files assembly...
Are Windows exe files written in assembly
If no, then in what language
From where can I learn the language in which exe files are written

Each of these questions were addressed by Griff. If your question wasn't addressed, it's because you didn't ask it.

You'll need to study the architecture of (at least) the x86 family of processors. A compiler-course would be beneficial.
You may find it useful to read-up on Lex, Yacc and Bison.

Be aware - this is far from trivial.
You may find some value in coding an assembler for a fairly basic cpu - one without all of the addressing-modes of the x86 architecture may well be manageable on your own.

20 odd years ago we wrote assemblers for the 6501/6502 processors. It actually wasn't that hard at all - it was only a 3 or 4 week assignment. You can see in the following link that the 6502 is really quite simple: MOS Technology 6502 cpu

Just look-up the opcodes for the various mnemonics and you should be good to go.
Wendelius 26-Jul-15 5:38am    
+5 just for the BrainF... alone :laugh:
Afzaal Ahmad Zeeshan 26-Jul-15 8:09am    
OriginalGriff, the term is Assembly, not Assembler. I would say, the post needs an edit. :-) Assembler is just the program that converts those commands (written in Assembly) into machine executable instructions.

I would personally also prefer C#, who needs to write 100 lines for a hello world program and another 500 to manage the memory. ;-)
OriginalGriff 26-Jul-15 8:29am    
Um...you sure? :laugh:
http://searchdatacenter.techtarget.com/definition/assembler
"An assembler is a program that takes basic computer instructions and converts them into a pattern of bits that the computer's processor can use to perform its basic operations. Some people call these instructions assembler language and others use the term assembly language."

The names are interchangeable - and have been since I started with PDP8 assembler way back when...
In addition to existing answers:

First of all, files like .EXE and .DLL are not assemblies. They are all executable files in the form of PE file. From the .NET standpoint, they are modules of the assemblies, not assemblies themselves.
Please see:
https://en.wikipedia.org/wiki/Portable_Executable[^],
https://en.wikipedia.org/wiki/Assembly_%28CLI%29[^].

One of the main contributors to the common confusion is Visual Studio, which directly support only the assemblies with only one module. But you can develop with just the compiler, which allows to create a module, not assembly, and then put module together and give assembly manifest only to one module. This way, an assembly will have several files, all being executable modules of the same assembly.

Still, reflection allows you to load and assembly and see what are the modules, so the possibility of having several modules is in the .NET BCL. See also: https://en.wikipedia.org/wiki/Manifest_(CLI)[^].

Also, it's good to know that there is not essential difference between .EXE and .DLL. They are just naming conventions. Normally, there are library assemblies which are allowed to be compiled without entry point (Main method). It's not very obvious fact, but EXE assemblies can be referenced exactly as libraries (DLL assemblies). There are even cases when it can be a useful programming technique.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900