2017-09-06 12:22:23 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
#ifdef __BYTE_ORDER__
|
|
|
|
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
|
|
# define HOST_LITTLE_ENDIAN
|
|
|
|
# endif
|
|
|
|
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
|
|
# define HOST_BIG_ENDIAN
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# if defined(_M_X64) || defined(_M_IX86)
|
|
|
|
# define HOST_LITTLE_ENDIAN
|
|
|
|
# else
|
|
|
|
# define HOST_BIG_ENDIAN
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace EightBit {
|
2018-06-15 23:55:32 +00:00
|
|
|
union register16_t {
|
2017-09-06 12:22:23 +00:00
|
|
|
struct {
|
|
|
|
#ifdef HOST_LITTLE_ENDIAN
|
|
|
|
uint8_t low;
|
|
|
|
uint8_t high;
|
|
|
|
#endif
|
|
|
|
#ifdef HOST_BIG_ENDIAN
|
|
|
|
uint8_t high;
|
|
|
|
uint8_t low;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
uint16_t word;
|
2018-06-15 23:55:32 +00:00
|
|
|
register16_t() : word(0) {}
|
|
|
|
register16_t(uint16_t w) : word(w) {}
|
|
|
|
register16_t(uint8_t l, uint8_t h) : low(l), high(h) {}
|
|
|
|
} ;
|
2017-11-30 23:19:17 +00:00
|
|
|
}
|