Skip to content

Commit

Permalink
duplicate memory size check removed
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed Jun 20, 2024
1 parent fcff5f8 commit e120309
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,13 +873,17 @@ void bus::write_word(const uint16_t a, const uint16_t value, const d_i_space_t s

uint8_t bus::read_unibus_byte(const uint32_t a)
{
uint8_t v = m->read_byte(a);
uint8_t v = 0;
if (a < m->get_memory_size())
v = m->read_byte(a);
TRACE("read_unibus_byte[%08o]=%03o", a, v);
return v;
}

void bus::write_unibus_byte(const uint32_t a, const uint8_t v)
{
TRACE("write_unibus_byte[%08o]=%03o", a, v);
m->write_byte(a, v);

if (a < m->get_memory_size())
m->write_byte(a, v);
}
4 changes: 2 additions & 2 deletions memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class memory
static memory *deserialize(const JsonVariantConst j);

uint16_t read_byte(const uint32_t a) const { return m[a]; }
void write_byte(const uint32_t a, const uint16_t v) { if (a < size) m[a] = v; }
void write_byte(const uint32_t a, const uint16_t v) { m[a] = v; }

uint16_t read_word(const uint32_t a) const { return m[a] | (m[a + 1] << 8); }
void write_word(const uint32_t a, const uint16_t v) { if(a < size - 1) { m[a] = v; m[a + 1] = v >> 8; } }
void write_word(const uint32_t a, const uint16_t v) { m[a] = v; m[a + 1] = v >> 8; }
};

0 comments on commit e120309

Please sign in to comment.