mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-19 21:55:11 +00:00
35 lines
576 B
C++
35 lines
576 B
C++
//
|
|
// Created by anonymus-raccoon on 1/28/20.
|
|
//
|
|
|
|
#include "Ram.hpp"
|
|
#include "../Exceptions/InvalidAddress.hpp"
|
|
|
|
namespace ComSquare::Ram
|
|
{
|
|
Ram::Ram(size_t size)
|
|
: _size(size)
|
|
{
|
|
this->_data = new uint8_t[size];
|
|
}
|
|
|
|
Ram::~Ram()
|
|
{
|
|
delete[] this->_data;
|
|
}
|
|
|
|
uint8_t Ram::read_internal(uint24_t addr)
|
|
{
|
|
if (addr >= this->_size)
|
|
throw InvalidAddress("Ram read", addr);
|
|
return this->_data[addr];
|
|
}
|
|
|
|
void Ram::write_internal(uint24_t addr, uint8_t data)
|
|
{
|
|
if (addr >= this->_size)
|
|
throw InvalidAddress("Ram write", addr);
|
|
this->_data[addr] = data;
|
|
}
|
|
}
|