diff options
Diffstat (limited to 'qtmips_machine/tests/testmemory.cpp')
-rw-r--r-- | qtmips_machine/tests/testmemory.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/qtmips_machine/tests/testmemory.cpp b/qtmips_machine/tests/testmemory.cpp index 991e1f1..eac7dd6 100644 --- a/qtmips_machine/tests/testmemory.cpp +++ b/qtmips_machine/tests/testmemory.cpp @@ -59,3 +59,25 @@ void MachineTests::memory_section() { // Read trough memory QCOMPARE(m.read_byte(address), (std::uint8_t)0x66); } + +void MachineTests::memory_endian() { + Memory m; + + // Memory should be bit endian so write bytes from most significant byte + m.write_byte(0x00, 0x12); + m.write_byte(0x01, 0x34); + m.write_byte(0x02, 0x56); + m.write_byte(0x03, 0x78); + QCOMPARE(m.read_hword(0x00), (std::uint16_t)0x1234); + QCOMPARE(m.read_word(0x00), (std::uint32_t)0x12345678); + + m.write_hword(0x80, 0x1234); + QCOMPARE(m.read_byte(0x80), (std::uint8_t)0x12); + QCOMPARE(m.read_byte(0x81), (std::uint8_t)0x34); + + m.write_word(0xF0, 0x12345678); + QCOMPARE(m.read_byte(0xF0), (std::uint8_t)0x12); + QCOMPARE(m.read_byte(0xF1), (std::uint8_t)0x34); + QCOMPARE(m.read_byte(0xF2), (std::uint8_t)0x56); + QCOMPARE(m.read_byte(0xF3), (std::uint8_t)0x78); +} |