refactor: reorganize everything

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-10-04 01:41:38 +05:30
parent 36d71a4ee2
commit e0f7f32699
28 changed files with 297 additions and 338 deletions

View File

@@ -21,7 +21,7 @@ Bus::read_halfword(size_t address) {
if (address & 0b01)
glogger.warn("Reading a non aligned halfword address");
return memory->read(address) | memory->read(address + 1) << 8;
return read_byte(address) | read_byte(address + 1) << 8;
}
void
@@ -29,8 +29,8 @@ Bus::write_halfword(size_t address, uint16_t halfword) {
if (address & 0b01)
glogger.warn("Writing to a non aligned halfword address");
memory->write(address, halfword & 0xFF);
memory->write(address + 1, halfword >> 8 & 0xFF);
write_byte(address, halfword & 0xFF);
write_byte(address + 1, halfword >> 8 & 0xFF);
}
uint32_t
@@ -38,8 +38,8 @@ Bus::read_word(size_t address) {
if (address & 0b11)
glogger.warn("Reading a non aligned word address");
return memory->read(address) | memory->read(address + 1) << 8 |
memory->read(address + 2) << 16 | memory->read(address + 3) << 24;
return read_byte(address) | read_byte(address + 1) << 8 |
read_byte(address + 2) << 16 | read_byte(address + 3) << 24;
}
void
@@ -47,9 +47,9 @@ Bus::write_word(size_t address, uint32_t word) {
if (address & 0b11)
glogger.warn("Writing to a non aligned word address");
memory->write(address, word & 0xFF);
memory->write(address + 1, word >> 8 & 0xFF);
memory->write(address + 2, word >> 16 & 0xFF);
memory->write(address + 3, word >> 24 & 0xFF);
write_byte(address, word & 0xFF);
write_byte(address + 1, word >> 8 & 0xFF);
write_byte(address + 2, word >> 16 & 0xFF);
write_byte(address + 3, word >> 24 & 0xFF);
}
}