Skip to content

Commit

Permalink
[svn] Implemented byteswapping.
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
icculus committed Feb 9, 2008
1 parent e19b529 commit 3f09865
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion parse.c
Expand Up @@ -11,11 +11,26 @@ static int FAIL(const char *reason)
} // FAIL


#define SWAP32(x) (x)
typedef unsigned int uint; // this is a printf() helper. don't use for code.
typedef uint8_t uint8;
typedef uint32_t uint32;

#if ((defined __GNUC__) && (defined __POWERPC__))
static inline uint32 SWAP32(uint32 x)
{
__asm__ __volatile__("lwbrx %0,0,%1" : "=r" (x) : "r" (&x));
return x;
} // SWAP32
#elif defined(__POWERPC__)
static inline uint32 SWAP32(uint32 x)
{
return ( (((x) >> 24) & 0x000000FF) | (((x) >> 8) & 0x0000FF00) |
(((x) << 8) & 0x00FF0000) | (((x) << 24) & 0xFF000000) );
} // SWAP32
#else
# define SWAP32(x) (x)
#endif

typedef int (*parse_instruction_function)(const uint32 *argtokens);

static int parse_NOP(const uint32 *argtokens)
Expand Down

0 comments on commit 3f09865

Please sign in to comment.