Reply 40 of 54, by sliderider
- Rank
- l33t++
wrote:Because you don't write x86/ppc/arm code. […]
wrote:"and no, again your lack of knowledge, these days, for true porting, you can reuse almost all of the code. Most of the times you just need some ifdef PLATFORMNAME and a compiler targeting that platform."
So tell me then, how do you port a game written in x86 code to say, a PowerPC processor, and still use the x86 code? How does the PowerPC processor interpret and run the code? You have to discard the x86 code and replace it with PowerPC code. I don't care if you use something like a cross compiler to translate x86->PowerPC, the finished product on the PowerPC machine still is NOT running x86 code. There is ZERO x86 code in the finished port.
Because you don't write x86/ppc/arm code.
You write in C/C++, or an equivalent, which is a (mostly) platform agnostic language. That code (which is simply text, there's nothing about it that ties it to one cpu architecture or another) is then turned into an executeable binary (your 'x86 code') by a compiler and linked to any supporting library routines (eg for input/output, audio playback, video compression etc).
As long as someone supplies a working c compiler, linker and the correct libraries, your C code will compile to a runnable programme for any platform.
It seems as though you believe that everything is written in assembly language, or even machine code specific to the host machine. That may have been true in 8bit and early 16bit home computer era, but it hasn't been the case for a long, long time.
C is a language that still has to be translated into native code that the target CPU can understand at the instruction set level. You might be able to code in a high level language on any machine, but the CPU still has to be able to execute it using commands from it's native instruction set. An Intel system still understands only x86 instructions, regardless of what high level language you use. It does not run C code directly. When you compile, it becomes instructions that the CPU can use. If you compile for x86, that same compiled code will NOT run on a 68k or PowerPC machine. You have to compile it into those machines' own native instructions to run it. Why isn't anyone understanding that?