# PPC and x86

This topic is 3563 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, i was just wondering if someone can provide some sample code of what would compile on x86 based machines that wouldnt on PPC based machine. Im confused a little bit as to why code wouldnt work on ppc if it does on x86 thanks

##### Share on other sites
Quote:
 Original post by b1gjo3Hi, i was just wondering if someone can provide some sample code of what would compile on x86 based machines that wouldnt on PPC based machine. Im confused a little bit as to why code wouldnt work on ppc if it does on x86thanks

Because they're COMPLETELY different architectures. Not just that. Different OS as well.
Since Windows is not on PPC, any Win32 specific feature (DirectX, GDI, HWND, ShellAPI, AdvaAPI, user32.dll, commdlg.dll, etc) won't work on the PPC.

High-level launguages' code (i.e. C, Pascal, Python) will work on a PPC machine as long as there's a compiler that supports that language for PPC.
But there are some platform-specific features that won't work, for example the MMX & SSE intrinsics for C++; because such technology is only available on x86.

If you're talking about low-level languages (i.e. assembly) then it won't work unless you're using an emulator (which is slow) You'll need to completely rewrite the code. See XviD how manages it. XviD doesn't "magically" compile on the PPC. Also try compiling the ddshow filter or the vfw interface. You can't

Besides there may be specific implementation details: like handling I/O ports and other devices. Those routine will most likely need to be rewritten.

Why the assembly won't work? Simple: they're too different.
x86 work on the following philosphy: A = A + B (which means, A is overwritten)
PPC work doing C = A + B
Plus, the instruction set, registers, number of register, state flags, and everything is just different. The only thing they have in common is that they operate with electricity, 0 and 1
But they operate in very different ways to achieve the same goal.
A car and a truck aren't the same just because they both work with gas, have room for passengers and allow travelling distances at high speeds

Cheers
Dark Sylinc

##### Share on other sites
Quote:
 Original post by b1gjo3Im confused a little bit as to why code wouldnt work on ppc if it does on x86

Here's a piece of code that behaves differently due to Endianness:
#include <stdio.h>union{    unsigned long foo;    unsigned char bar;} baz;int main(void){    baz.foo = 0xCAFEBABEul;    switch (baz.bar)    {        case 0xCA: printf("big endian\n"); break;        case 0xBE: printf("little endian\n"); break;        default: printf("you're weird\n");    }    return 0;}

##### Share on other sites
Quote:
 Original post by Matias GoldbergDifferent OS as well.

I believe b1gjo3 is referring to compiling code for OS X on PPC and x86.

##### Share on other sites
thanks everyone, that clears a lot of things up for me. much appreciation once again to the community on gamedev!

• 38
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631362
• Total Posts
2999577
×