home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / emulators / v9t9 / linux / sources / V9t9 / source / 16bit.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-19  |  778 b   |  46 lines

  1.  
  2. /*
  3.         16BIT.H
  4.         =======
  5.  
  6. */
  7.  
  8. #ifndef __16BIT__
  9. #define __16BIT__
  10.  
  11. #include "v9t9_types.h"
  12.  
  13. #include "centry.h"
  14.  
  15. #if defined(__i386__) || defined(__INTEL__)
  16. #define SWAPPED
  17. #else
  18. #error unknown byte order
  19. //#undef SWAPPED
  20. #endif
  21.  
  22. /*  for byte arrays */
  23.  
  24. #define WORD(ar,ad) (*(u16 *)((ar)+((ad)&0xfffe)))
  25.  
  26. #ifdef SWAPPED
  27. #define BYTE(ar,ad) (*(u8 *)((ar)+((ad)^1)))
  28. #else
  29. #define BYTE(ar,ad) (*(u8 *)((ar)+(ad)))
  30. #endif
  31.  
  32. #define FLAT_BYTE(ar,ad) (*(u8 *)((ar)+(ad)))
  33.  
  34. #ifdef SWAPPED
  35. #define TI2HOST(x) ( (((u16)(x) & 0xff) << 8) | (((u16)(x) >> 8) & 0xff) )
  36. #define HOST2TI TI2HOST
  37. #define SWAPTI(x) ((u16)(x))
  38. #else
  39. #define TI2HOST(x)    ((u16)(x))
  40. #define HOST2TI TI2HOST
  41. #define SWAPTI(x) ( (((u16)(x) & 0xff) << 8) | (((u16)(x) >> 8) & 0xff) )
  42. #endif
  43.  
  44. #include "cexit.h"
  45. #endif
  46.