I am trying to print a string in a way that’s OS-neutral. For example, the program should run the same on Windows as it does on *nix.
Is this even possible? I’m assuming that since the underlying architecture is the same (x86) that the method would be the same. Is it as simple as calling an interrupt?
The reason for this is I’m trying to write a compiler that generates assembly code – at this early point in its development, only a handful of features are present – I’d like to be able to test the generated assembly code in either Windows or *nix. Down the road, it will be impossible to maintain platform-neutrality while generating the same code, but basically all I want to do at this point is print a string.
Pure assembly should not be considered portable between operating systems. There is no universal way to interact with system services from assembly. You shouldn’t even assume portability between Unix-like OSes (POSIX doesn’t specify a calling convention, though some x86 Unices do use a common convention).
Even in higher-level languages, calling conventions can technically vary from one compiler to the next on the exact same CPU+OS, though usually compilers use whatever convention is specified for the host environment.
See also Wikipedia’s page on x86 calling conventions.