added constants/macros to help maintain endian changes

This commit is contained in:
unknown 2015-10-01 13:58:19 -04:00
parent f028d40910
commit 83f8586111
1 changed files with 19 additions and 1 deletions

View File

@ -30,7 +30,25 @@
#define Eip Rip #define Eip Rip
#endif #endif
extern unsigned long swap32by8(unsigned long word); /*
* This will help us gradually be able to port Project64 for big-endian CPUs
* later. Currently it is written to assume 32-bit little-endian, like so:
*
* 0xAABBCCDD EEFFGGHH --> 0xDDCCBBAA HHGGFFEE
* GPR bits[63..0] b1b2b3b4 b5b6b7b8
*/
#define BYTE_SWAP_MASK 3u
#define HALF_SWAP_MASK ((BYTE_SWAP_MASK) & ~1u)
#define WORD_SWAP_MASK ((BYTE_SWAP_MASK) & ~3u)
// Convert MIPS server-native byte order to client-native endian.
#define BES(offset) ((offset) ^ (BYTE_SWAP_MASK))
// Convert MIPS server-native halfword order to client-native int16_t order.
#define HES(offset) ((offset) ^ (HALF_SWAP_MASK))
// Convert MIPS server-native word order to client-native int32_t order.
#define WES(offset) ((offset) ^ (WORD_SWAP_MASK))
class CMipsMemoryVM : class CMipsMemoryVM :
public CMipsMemory, public CMipsMemory,