Add typedef for memory
MODIFY
src/defines.h
src/defines.h
#ifndef DEFINES_H
#define DEFINES_H
+#include "unordered_map"
#include <QString>
#include <cstdint>
#include <map>
@@ -24,7 +25,7 @@ enum cacheLevel { L1 = 0, L2 = 1, L3 = 2 };
enum cacheType { DM, SA, FA };
-typedef std::vector<uint8_t> memory;
+typedef std::unordered_map<uint32_t, uint8_t> memory;
enum instrState {
ERR_BFUNCT3,

MODIFY
src/memorytab.h
src/memorytab.h
#ifndef MEMORYTAB_H
#define MEMORYTAB_H
+#include "defines.h"
+
#include <QWidget>
#include <unordered_map>
@@ -17,9 +19,7 @@ public:
explicit MemoryTab(QWidget *parent = 0);
~MemoryTab();
- void setMemoryPtr(std::unordered_map<uint32_t, uint8_t> *ptr) {
- m_memoryPtr = ptr;
- }
+ void setMemoryPtr(memory *ptr) { m_memoryPtr = ptr; }
void setRegPtr(std::vector<uint32_t> *ptr) { m_regPtr = ptr; }
void init();
@@ -31,7 +31,7 @@ private:
Ui::MemoryTab *m_ui;
- std::unordered_map<uint32_t, uint8_t> *m_memoryPtr;
+ memory *m_memoryPtr;
std::vector<uint32_t> *m_regPtr;
std::vector<RegisterWidget *> m_regWidgetPtrs;

MODIFY
src/parser.cpp
src/parser.cpp
@@ -25,11 +25,11 @@ bool Parser::init(char *filename) {
Parser::~Parser() {}
-void Parser::parseFile(std::unordered_map<uint32_t, uint8_t> *memory) {
+void Parser::parseFile(memory *memoryPtr) {
// Parse the file in 8-bit segments and write to memory map
int pc = 0;
while (m_fileIter != istreambuf_iterator<char>()) {
- (*memory)[pc] = *m_fileIter;
+ (*memoryPtr)[pc] = *m_fileIter;
pc++;
m_fileIter++;
}

MODIFY
src/parser.h
src/parser.h
@@ -17,7 +17,7 @@ public:
public:
bool init(char *filename);
- void parseFile(std::unordered_map<uint32_t, uint8_t> *memory);
+ void parseFile(memory *memoryPtr);
private:
ifstream m_fileStream;

MODIFY
src/runner.h
src/runner.h
@@ -20,7 +20,7 @@ public:
int exec();
RunnerCache *getRunnerCachePtr() { return &m_cache; }
- std::unordered_map<uint32_t, uint8_t> *getMemoryPtr() { return &m_memory; }
+ memory *getMemoryPtr() { return &m_memory; }
std::vector<uint32_t> *getRegPtr() { return &m_reg; }
private:
@@ -41,7 +41,7 @@ private:
std::vector<uint8_t> m_heap;
const uint32_t m_heapStart = 0x10008000;
- std::unordered_map<uint32_t, uint8_t> m_memory;
+ memory m_memory;
void memWrite(uint32_t address, uint32_t value, int size);
uint32_t memRead(uint32_t address);

Add typedef for memory