memory handling changes:
- no assert when accessing memory beyond boundaries, bus should take care of this - getting (slowly) rid of camelcasing
This commit is contained in:
parent
a2acf902c7
commit
b139ddfd92
4 changed files with 18 additions and 18 deletions
16
bus.cpp
16
bus.cpp
|
@ -525,9 +525,9 @@ uint16_t bus::read(const uint16_t addr_in, const word_mode_t word_mode, const rm
|
|||
|
||||
uint16_t temp = 0;
|
||||
if (word_mode == wm_byte)
|
||||
temp = m->readByte(m_offset);
|
||||
temp = m->read_byte(m_offset);
|
||||
else
|
||||
temp = m->readWord(m_offset);
|
||||
temp = m->read_word(m_offset);
|
||||
|
||||
if (!peek_only) DOLOG(debug, false, "READ from %06o/%07o %c %c: %o (%s)", addr_in, m_offset, space == d_space ? 'D' : 'I', word_mode == wm_byte ? 'B' : 'W', temp, mode_selection == rm_prev ? "prev" : "cur");
|
||||
|
||||
|
@ -1039,9 +1039,9 @@ write_rc_t bus::write(const uint16_t addr_in, const word_mode_t word_mode, uint1
|
|||
}
|
||||
|
||||
if (word_mode == wm_byte)
|
||||
m->writeByte(m_offset, value);
|
||||
m->write_byte(m_offset, value);
|
||||
else
|
||||
m->writeWord(m_offset, value);
|
||||
m->write_word(m_offset, value);
|
||||
|
||||
return { false };
|
||||
}
|
||||
|
@ -1056,7 +1056,7 @@ void bus::writePhysical(const uint32_t a, const uint16_t value)
|
|||
throw 12;
|
||||
}
|
||||
else {
|
||||
m->writeWord(a, value);
|
||||
m->write_word(a, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1068,7 +1068,7 @@ uint16_t bus::readPhysical(const uint32_t a)
|
|||
throw 13;
|
||||
}
|
||||
|
||||
uint16_t value = m->readWord(a);
|
||||
uint16_t value = m->read_word(a);
|
||||
|
||||
DOLOG(debug, false, "physicalREAD %06o from %o", value, a);
|
||||
|
||||
|
@ -1092,7 +1092,7 @@ void bus::writeWord(const uint16_t a, const uint16_t value, const d_i_space_t s)
|
|||
|
||||
uint8_t bus::readUnibusByte(const uint32_t a)
|
||||
{
|
||||
uint8_t v = m->readByte(a);
|
||||
uint8_t v = m->read_byte(a);
|
||||
DOLOG(debug, false, "readUnibusByte[%08o]=%03o", a, v);
|
||||
return v;
|
||||
}
|
||||
|
@ -1100,5 +1100,5 @@ uint8_t bus::readUnibusByte(const uint32_t a)
|
|||
void bus::writeUnibusByte(const uint32_t a, const uint8_t v)
|
||||
{
|
||||
DOLOG(debug, false, "writeUnibusByte[%08o]=%03o", a, v);
|
||||
m->writeByte(a, v);
|
||||
m->write_byte(a, v);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
// (C) 2018-2023 by Folkert van Heusden
|
||||
// (C) 2018-2024 by Folkert van Heusden
|
||||
// Released under MIT license
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "memory.h"
|
||||
|
||||
|
||||
memory::memory(const uint32_t size) : size(size)
|
||||
{
|
||||
#if defined(ESP32)
|
||||
|
|
11
memory.h
11
memory.h
|
@ -2,8 +2,7 @@
|
|||
// Released under MIT license
|
||||
|
||||
#pragma once
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
#include "gen.h"
|
||||
|
||||
|
@ -26,9 +25,9 @@ public:
|
|||
static memory *deserialize(const json_t *const j);
|
||||
#endif
|
||||
|
||||
uint16_t readByte(const uint32_t a) const { return m[a]; }
|
||||
void writeByte(const uint32_t a, const uint16_t v) { assert(a < size); m[a] = v; }
|
||||
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; }
|
||||
|
||||
uint16_t readWord(const uint32_t a) const { return m[a] | (m[a + 1] << 8); }
|
||||
void writeWord(const uint32_t a, const uint16_t v) { assert(a < size - 1); m[a] = v; m[a + 1] = v >> 8; }
|
||||
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; } }
|
||||
};
|
||||
|
|
|
@ -113,14 +113,14 @@ void tm_11::writeWord(const uint16_t addr, uint16_t v)
|
|||
if (fread(xfer_buffer, 1, reclen, fh) != reclen)
|
||||
DOLOG(info, true, "failed: %s", strerror(errno));
|
||||
for(int i=0; i<reclen; i++)
|
||||
m -> writeByte(registers[(TM_11_MTCMA - TM_11_BASE) / 2] + i, xfer_buffer[i]);
|
||||
m->write_byte(registers[(TM_11_MTCMA - TM_11_BASE) / 2] + i, xfer_buffer[i]);
|
||||
offset += reclen;
|
||||
|
||||
v = 128; // TODO set error if error
|
||||
}
|
||||
else if (func == 2) { // write
|
||||
for(int i=0; i<reclen; i++)
|
||||
xfer_buffer[i] = m -> readByte(registers[(TM_11_MTCMA - TM_11_BASE) / 2] + i);
|
||||
xfer_buffer[i] = m->read_byte(registers[(TM_11_MTCMA - TM_11_BASE) / 2] + i);
|
||||
fwrite(xfer_buffer, 1, reclen, fh);
|
||||
offset += reclen;
|
||||
v = 128; // TODO
|
||||
|
|
Loading…
Add table
Reference in a new issue