mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 18:30:21 +00:00
Correct unaligned accesses.
This commit is contained in:
parent
fbc273f114
commit
21278d028c
@ -290,6 +290,10 @@ struct Memory {
|
|||||||
bool write(uint32_t address, IntT source, InstructionSet::ARM::Mode mode, bool trans) {
|
bool write(uint32_t address, IntT source, InstructionSet::ARM::Mode mode, bool trans) {
|
||||||
(void)trans;
|
(void)trans;
|
||||||
|
|
||||||
|
if constexpr (std::is_same_v<IntT, uint32_t>) {
|
||||||
|
address &= static_cast<uint32_t>(~3);
|
||||||
|
}
|
||||||
|
|
||||||
// if(address == 0x0200002c && address < 0x04000000) {
|
// if(address == 0x0200002c && address < 0x04000000) {
|
||||||
// if(address == 0x02000074) {
|
// if(address == 0x02000074) {
|
||||||
// printf("%08x <- %08x\n", address, source);
|
// printf("%08x <- %08x\n", address, source);
|
||||||
@ -363,6 +367,12 @@ struct Memory {
|
|||||||
|
|
||||||
template <typename IntT>
|
template <typename IntT>
|
||||||
bool read(uint32_t address, IntT &source, InstructionSet::ARM::Mode mode, bool trans) {
|
bool read(uint32_t address, IntT &source, InstructionSet::ARM::Mode mode, bool trans) {
|
||||||
|
// Unaligned addresses are presented on the bus, but in an Archimedes
|
||||||
|
// the bus will ignore the low two bits.
|
||||||
|
if constexpr (std::is_same_v<IntT, uint32_t>) {
|
||||||
|
address &= static_cast<uint32_t>(~3);
|
||||||
|
}
|
||||||
|
|
||||||
(void)trans;
|
(void)trans;
|
||||||
// logger.info().append("R %08x", address);
|
// logger.info().append("R %08x", address);
|
||||||
|
|
||||||
|
@ -65,6 +65,9 @@ struct Memory {
|
|||||||
struct MemoryLedger {
|
struct MemoryLedger {
|
||||||
template <typename IntT>
|
template <typename IntT>
|
||||||
bool write(uint32_t address, IntT source, Mode, bool) {
|
bool write(uint32_t address, IntT source, Mode, bool) {
|
||||||
|
if constexpr (std::is_same_v<IntT, uint32_t>) {
|
||||||
|
address &= static_cast<uint32_t>(~3);
|
||||||
|
}
|
||||||
if(write_pointer == writes.size() || writes[write_pointer].size != sizeof(IntT) || writes[write_pointer].address != address || writes[write_pointer].value != source) {
|
if(write_pointer == writes.size() || writes[write_pointer].size != sizeof(IntT) || writes[write_pointer].address != address || writes[write_pointer].value != source) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -74,6 +77,10 @@ struct MemoryLedger {
|
|||||||
|
|
||||||
template <typename IntT>
|
template <typename IntT>
|
||||||
bool read(uint32_t address, IntT &source, Mode, bool) {
|
bool read(uint32_t address, IntT &source, Mode, bool) {
|
||||||
|
if constexpr (std::is_same_v<IntT, uint32_t>) {
|
||||||
|
address &= static_cast<uint32_t>(~3);
|
||||||
|
}
|
||||||
|
|
||||||
if(read_pointer == reads.size() || reads[read_pointer].size != sizeof(IntT) || reads[read_pointer].address != address) {
|
if(read_pointer == reads.size() || reads[read_pointer].size != sizeof(IntT) || reads[read_pointer].address != address) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user