Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Executable able to run on different CPUs for Windows

I heard that Assembly Languages are depending on the CPU, and the fact that a .exe file can mostly all Windows machine. Makes me wonder how does that work?

Does that imply that there are only a few Assembly languages?

or Does the Windows System do some sort of translation to fit different type of CPUs?

like image 379
Eds Avatar asked Oct 16 '25 14:10

Eds


1 Answers

The simple answer:

They cannot be executed on "different CPUs".

The more complex answer:

Most computers running Windows use only two different types of CPUs: x86 or x86-64.

  • x86-64 is compatible with x86 so you can run an executable compiled for x86 on an x86-64 CPU.
  • You cannot run an executable compiled for x86-64 on an x86 CPU.
  • There are Windows computers using different CPUs (ARM, MIPS, SuperH...). You cannot run an executable compiled for these CPUs on x86-64 nor on x86 CPUs. On the other hand you can only run executables compiled for the specific CPU type (ARM, MIPS, SuperH...) on such a computer.

Then there are so called ".NET" executables. Such executables do not contain any machine code but they contain special byte code (similar to Java programs).

When you run the program the first time on a certain computer Windows will translate that byte code into machine code suitable for the computer you run the program on. If you run the program on an ARM computer the byte code will be translated into an ARM program.

The computer will actually execute the "translation", not the original ".NET" executable.

Because the "translation" is done for a specific computer there is no need to be executable on different CPUs.

like image 146
Martin Rosenau Avatar answered Oct 18 '25 07:10

Martin Rosenau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!