replaced c-style array with c++ array
This commit is contained in:
@@ -10,9 +10,9 @@ Memory *Memory::getInstance() {
|
||||
}
|
||||
|
||||
void Memory::store(const int address, const int value) {
|
||||
m_memory[address] = value;
|
||||
m_memory.at(address) = value;
|
||||
}
|
||||
|
||||
int Memory::load(const int address) const {
|
||||
return m_memory[address];
|
||||
return m_memory.at(address);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#ifndef MEMORY_H
|
||||
#define MEMORY_H
|
||||
#include <array>
|
||||
|
||||
/// Eine Hauptspeicherklasse als Singleton implementiert.
|
||||
/// Als Hauptspeicher wird ein Array genutzt.
|
||||
@@ -17,7 +18,7 @@ private:
|
||||
/// Singleton instance
|
||||
static Memory *m_instance;
|
||||
/// Hauptspeicher (hier 32 kB groß)
|
||||
int m_memory[8192];
|
||||
std::array<int, 8192> m_memory;
|
||||
|
||||
public:
|
||||
/// Singleton Logik
|
||||
|
||||
@@ -11,9 +11,9 @@ Register& Register::getInstance() {
|
||||
}
|
||||
|
||||
void Register::setRegister(const int reg, const int value) {
|
||||
m_registers[reg] = value;
|
||||
m_registers.at(reg) = value;
|
||||
}
|
||||
|
||||
int Register::getRegister(const int reg) const {
|
||||
return m_registers[reg];
|
||||
return m_registers.at(reg);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#ifndef REGISTER_H
|
||||
#define REGISTER_H
|
||||
#include <array>
|
||||
|
||||
/// Eine Registerklasse als Singleton implementiert.
|
||||
/// Als Speicher (Registers) wird ein int Array genutzt.
|
||||
@@ -17,7 +18,7 @@ private:
|
||||
/// Singleton instance
|
||||
static Register *m_instance;
|
||||
/// "Echter" Register Speicher
|
||||
int m_registers[32];
|
||||
std::array<int, 32> m_registers;
|
||||
|
||||
public:
|
||||
/// Singleton Logik
|
||||
|
||||
Reference in New Issue
Block a user