It is possible to create an executable file that
identifies the OS that it
is running on and does a conditional jump to different code, assuming that
the processor uses the same instruction set.
In some cases it should be possible to write a machine code program that executes
on 2 processors with wildly different instruciton sets.
One way that spring to mind (assuming instructions are a 1 or more bytes long) is to
find a byte which :
Processor A interprets as a single byte instruction
Processor B interprets as a 16 bit load to a register, hence taking 2 bytes of operand
Start the program with that byte, then put a 2-byte relative branch instruction in
Processor A machine code.
Processor A then reads the single byte instrucion and executes it (not doing a lot), then
runs the relative branch, goes off somewhere where there is pure Processor A code
Processor B reads the values for the relative branch into a register (which does no
damage)
then contines with the 4th byte of the program, which is pure Processor B code.
There are plenty of other ways to do it, I suspect certainly in some cases the right
instruction
bytes exist.
It is even possible to make a disk that is readable as
multiple disk
formats, so long as each is expecting the DIRectory tracks to be in
different places.
The OS-9 Level II distribution disk for the CoCo 3 is like that. It is mostly OS-9 format
(which
assumes some kind of pointers, if not the root directory, in cylinder 0). One file,
carefully postioned
at the middle track number, is actually a Color TRS-DOS directory and a couple of
programs. Said
directory appears to contain a very large (non-contiguous) file covering most of the disk,
along with
a couple of utilities (a bootstrap for the older version disk controller ROM being the
main one).
So when used under OS-9 it acts normally (directory where the OS expects to find it), just
with
this apparently useless file. Ditto under Color TRS-DOS.
-tony