Skip to content
Permalink
Browse files
[svn] Implemented byteswapping.
--HG--
branch : trunk
  • Loading branch information
icculus committed Feb 9, 2008
1 parent e19b529 commit 3f098657707e3bef37b62dcd8c9b0cc08135af57

File 1 of 1 in 3f09865

17 parse.c
@@ -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)

0 comments on commit 3f09865

Please sign in to comment.