aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/programmemory.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-02 15:34:07 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-02 15:34:07 +0200
commit375607d9969896c894fa2642ce4a0b8b519a2adb (patch)
treecb947a843d85f1cd278da15cff432c849986166c /qtmips_machine/programmemory.cpp
parent82884b3ef726889f837542d2b5e98e2cd8246c00 (diff)
downloadqtmips-375607d9969896c894fa2642ce4a0b8b519a2adb.tar.gz
qtmips-375607d9969896c894fa2642ce4a0b8b519a2adb.tar.bz2
qtmips-375607d9969896c894fa2642ce4a0b8b519a2adb.zip
Use QString and QVector instead of std ones and more
Diffstat (limited to 'qtmips_machine/programmemory.cpp')
-rw-r--r--qtmips_machine/programmemory.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/qtmips_machine/programmemory.cpp b/qtmips_machine/programmemory.cpp
index 1ff3bca..74b16a8 100644
--- a/qtmips_machine/programmemory.cpp
+++ b/qtmips_machine/programmemory.cpp
@@ -5,14 +5,16 @@
#include "instructions/loadstore.h"
#include "instructions/nop.h"
#include "instructions/shift.h"
-#include "utils.h"
-ProgramMemory::ProgramMemory(ProgramLoader *loader, MemoryAccess *memory) {
+ProgramMemory::ProgramMemory(MemoryAccess *memory) {
this->memory = memory;
+}
+
+void ProgramMemory::load(ProgramLoader *loader) {
// Load program to memory (just dump it byte by byte, decode is done on demand)
for (int i = 0; i < loader->get_nsec(); i++) {
std::uint32_t base_address = loader->get_address(i);
- std::vector<std::uint8_t> data = loader->get_data(i);
+ QVector<std::uint8_t> data = loader->get_data(i);
for (auto it = data.begin(); it < data.end(); it++) {
memory->write_byte(base_address + i, *it);
}
@@ -40,7 +42,7 @@ Instruction *ProgramMemory::at(std::uint32_t address) {
}
}
-#define I_UNKNOWN(DATA) throw QTMIPS_EXCEPTION(UnsupportedInstruction, "Unknown instruction, can't decode", to_string_hex(DATA))
+#define I_UNKNOWN(DATA) throw QTMIPS_EXCEPTION(UnsupportedInstruction, "Unknown instruction, can't decode", QString::number(DATA, 16))
#define I_UNSUPPORTED(INST) throw QTMIPS_EXCEPTION(UnsupportedInstruction, "Decoded unsupported unstruction", #INST)
Instruction *ProgramMemory::decode_r(std::uint32_t dt) {