-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory.cpp
37 lines (34 loc) · 865 Bytes
/
memory.cpp
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
#include <iostream>
class Memory
{
private:
int memory_addresses[65536];
public:
Memory()
{
initializeMemoryAddresses();
}
void initializeMemoryAddresses()
{
int NULL_VAL = 0x00;
for(int i = 0; i < 65536; i++)
memory_addresses[i] = NULL_VAL;
}
void printMemoryAddress(int* memoryAddress)
{
std::cout << memory_addresses[*memoryAddress] << std::endl;
}
void setMemoryAddress(int* memoryAddress, int* val)
{
memory_addresses[*memoryAddress] = *val;
}
};
int main()
{
Memory RAM;
int memoryAddress = 0x00;
int val = 0x33;
RAM.printMemoryAddress(&memoryAddress);
RAM.setMemoryAddress(&memoryAddress, &val);
RAM.printMemoryAddress(&memoryAddress);
}