-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory.h
46 lines (33 loc) · 1013 Bytes
/
memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Created by michal on 16.09.17.
//
#ifndef PROJECT_MEMORY_H
#define PROJECT_MEMORY_H
#include <vector>
#include <string>
enum DataType {
Byte = 1,
Word = 2,
Dword = 4,
Qword = 8
};
static int id_to_data_type(std::string ®_id) {
if (reg_id == "00") return Byte;
if (reg_id == "10") return Word;
if (reg_id == "01") return Dword;
if (reg_id == "11") return Qword;
}
class Memory {
public:
explicit Memory(unsigned long size, uint32_t init_data_size) : size(size), init_data_size(init_data_size) {}
void initialize(std::vector<char> &buffer);
void save_data(std::vector<unsigned char>, int64_t offset);
std::vector<unsigned char> access_data(int offset, DataType data_type);
int64_t memory_to_int(std::vector<unsigned char> memory_slice);
void update(int64_t value, uint64_t offset, DataType data_type);
private:
unsigned long size;
uint32_t init_data_size;
std::vector<unsigned char> stored_data;
};
#endif //PROJECT_MEMORY_H