Sign in to follow this  

PPC and x86

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Quote:
Original post by b1gjo3
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


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 this post


Link to post
Share on other sites
Quote:
Original post by b1gjo3
Im 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 this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this