refactor: reorganize everything
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
18
src/bus.cc
18
src/bus.cc
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user