assembly on X86 machines, Windows vs Linux

jason picture jason · Jul 23, 2010 · Viewed 8.1k times · Source

Are they the same?

Longer version :

Say I wrote, in assembly, on a windows machine, a small app that all it does is add 1+1 and stores it in a register. THEN, I write the exact same code on a Linux machine. Would it work?

Im thinking yes, because at the hardware level, its the same machine, so the 'language of the hardware' (forgive the inexactness) would be the same.

So Im thinking a virus targeting windows but written in assembly wouldnt just be a windows virus.

Answer

Andreas Rejbrand picture Andreas Rejbrand · Jul 23, 2010

A virus will most certainly need to interact with the operating system, and use its API. Hence it is highly platform-dependant.

In addition, an executable also has a header, and this will depend on the targeted OS. If you would create a more or less empty EXE file in Windows, this would not run (not even start) under Linux.