bsnes/higan/processor/spc700/registers.hpp

52 lines
1.6 KiB
C++
Raw Normal View History

struct Flag {
inline operator uint() const {
2011-11-17 12:05:35 +00:00
return (n << 7) | (v << 6) | (p << 5) | (b << 4)
| (h << 3) | (i << 2) | (z << 1) | (c << 0);
}
inline auto operator=(uint8 data) -> uint {
n = data & 0x80; v = data & 0x40; p = data & 0x20; b = data & 0x10;
h = data & 0x08; i = data & 0x04; z = data & 0x02; c = data & 0x01;
return data;
}
inline auto operator|=(uint8 data) -> uint { return operator=(operator uint() | data); }
inline auto operator^=(uint8 data) -> uint { return operator=(operator uint() ^ data); }
inline auto operator&=(uint8 data) -> uint { return operator=(operator uint() & data); }
bool n, v, p, b, h, i, z, c;
2011-11-17 12:05:35 +00:00
};
struct Word {
inline operator uint() const { return w; }
inline auto operator=(uint data) -> uint { return w = data; }
2011-11-17 12:05:35 +00:00
inline auto operator++() -> uint { return ++w; }
inline auto operator--() -> uint { return --w; }
2011-11-17 12:05:35 +00:00
inline auto operator++(int) -> uint { unsigned data = w++; return data; }
inline auto operator--(int) -> uint { unsigned data = w--; return data; }
inline auto operator+=(uint data) -> uint { return w += data;; }
inline auto operator-=(uint data) -> uint { return w -= data;; }
2011-11-17 12:05:35 +00:00
inline auto operator|=(uint data) -> uint { return w |= data; }
inline auto operator^=(uint data) -> uint { return w ^= data; }
inline auto operator&=(uint data) -> uint { return w &= data; }
union {
uint16_t w;
struct { uint8_t order_lsb2(l, h); };
};
};
struct Regs {
Word pc;
2011-11-17 12:05:35 +00:00
union {
uint16_t ya;
struct { uint8_t order_lsb2(a, y); };
2011-11-17 12:05:35 +00:00
};
uint8_t x, s;
Flag p;
};