From 066a82e93ca7ea3c26091035b1d0a7fe49485c3d Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Sun, 24 Feb 2019 12:29:18 +0000 Subject: [PATCH] move parity into PROGMEM --- i8080.cpp | 6 +++--- i8080.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/i8080.cpp b/i8080.cpp index 0352d23..7e2d54d 100644 --- a/i8080.cpp +++ b/i8080.cpp @@ -84,7 +84,7 @@ void i8080::daa() { flags.C = c; } -int i8080::parity_table[] = { +const uint8_t parity_table[] PROGMEM = { 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, @@ -103,8 +103,8 @@ int i8080::parity_table[] = { 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, }; -i8080::i8080(Memory &m, PortDevice &d): CPU(m), _ports(&d) -{ +uint8_t parity_tbl(uint8_t r) { + return pgm_read_byte(parity_table + r); } void i8080::_op(uint8_t op) { diff --git a/i8080.h b/i8080.h index f2bd1e3..87bb9c9 100644 --- a/i8080.h +++ b/i8080.h @@ -5,9 +5,11 @@ #undef PC #undef SP +uint8_t parity_tbl(uint8_t); + class i8080: public CPU { public: - i8080(Memory &, PortDevice &); + i8080(Memory &m, PortDevice &d): CPU(m), _ports(&d) {} void run(unsigned); void reset(); @@ -62,8 +64,6 @@ private: void _op(uint8_t op); - static int parity_table[256]; - inline uint16_t _rw(Memory::address a) { return _mem[a] + (_mem[a+1] << 8); } @@ -76,7 +76,7 @@ private: inline void _szp(uint8_t r) { flags.S = ((r & 0x80) != 0); flags.Z = (r == 0); - flags.P = parity_table[r]; + flags.P = parity_tbl(r); } inline void _szhp(uint8_t b, uint8_t r) {