diff -r b997cbf9e30b -r 78c4d6b53499 c++/rgb-assembler/memory.h
--- a/c++/rgb-assembler/memory.h Mon Dec 25 00:24:07 2017 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/**
- * RGB assembler
- * Copyright © 2017 František Kučera (frantovo.cz)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include "types.h"
-
-const address_t MEMORY_SIZE = 1024;
-
-class Memory {
-private:
-
- template T logMemoryError(const address_t &index) {
- wprintf(L"memory error: index = %d, sizeof(T) = %d, MEMORY_SIZE = %d\n", index, sizeof (T), MEMORY_SIZE);
- // TODO: return error value or throw exception
- return T();
- }
- octet_t * memory;
- address_t index;
-
-public:
-
- Memory() {
- memory = (octet_t*) malloc(MEMORY_SIZE);
- index = 0;
- }
-
- virtual ~Memory() {
- free(memory);
- memory = nullptr;
- }
-
- /**
- * Reads data on given position in memory and increments the index (position).
- * @return value found at current position
- */
- template T read() {
- // TODO: map higher memory to static hardcoded areas or peripherals
- if (index + sizeof (T) <= MEMORY_SIZE) {
- T * value = reinterpret_cast (memory + index);
- index += sizeof (T);
- return *value;
- } else {
- return logMemoryError(index);
- }
- }
-
- /**
- * Writes data to current position in memory and increments the index (position).
- * @param value value to be written at given position
- */
- template T write(const T value) {
- if (index + sizeof (T) <= MEMORY_SIZE) {
- T * m = reinterpret_cast (memory + index);
- *m = value;
- index += sizeof (value);
- } else {
- return logMemoryError(index);
- }
- }
-
- void setIndex(address_t &index) {
- this->index = index;
- }
-
- address_t getIndex() {
- return index;
- }
-
- /**
- * FIXME: rename
- * @return
- */
- bool isInside() {
- return index < MEMORY_SIZE;
- }
-
- /**
- * FIXME: rename, refactor
- */
- void start() {
- index = 0;
- }
-
- /**
- * FIXME: rename, refactor
- */
- void finish() {
- index = MEMORY_SIZE;
- }
-};