This repository was archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
62 lines (52 loc) · 1.82 KB
/
main.cpp
File metadata and controls
62 lines (52 loc) · 1.82 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// Program: MARIE Computer Term Project
// Programmer: Raheem F.
// Purpose: Simulates a MARIE computer if one were to exist.
// main.cpp
#include <iostream>
#include <string>
#include "MarieComputer.h"
int main()
{
std::string memory[28];
memory[0] = "0001000000010001"; // Load Addr
memory[1] = "0010000000010010"; // Store Next
memory[2] = "0001000000010011"; // Load Num
memory[3] = "0100000000010110"; // Subt One
memory[4] = "0010000000010101"; // Store Ctr
memory[5] = "0001000000010100"; // LOOP: Load Sum
memory[6] = "1011000000010010"; // AddI Next
memory[7] = "0010000000010100"; // Store Sum
memory[8] = "0001000000010010"; // Load Next
memory[9] = "0011000000010110"; // Add One
memory[10] = "0010000000010010"; // Store Next
memory[11] = "0001000000010101"; // Load Ctr
memory[12] = "0100000000010110"; // Subt One
memory[13] = "0010000000010101"; // Store Ctr
memory[14] = "1000000000000000"; // Skipcond
memory[15] = "1001000000000101"; // Jump
memory[16] = "0111000000000000"; // Halt
memory[17] = "0000000000010111"; // Addr
memory[18] = "0000000000000000"; // Next
memory[19] = "0000000000000101"; // Num
memory[20] = "0000000000000000"; // Sum
memory[21] = "0000000000000000"; // Ctr
memory[22] = "0000000000000001"; // One
memory[23] = "0000000000001010"; // Dec 10
memory[24] = "0000000000001111"; // Dec 15
memory[25] = "0000000000010100"; // Dec 20
memory[26] = "0000000000011001"; // Dec 25
memory[27] = "0000000000011110"; // Dec 30
// Load memory into the CPU.
MarieComputer* mCPU = new MarieComputer( memory, 28 );
if ( !mCPU )
return 1;
mCPU->DisplayMemory(40);
mCPU->StartProgramLoadedInMemory();
mCPU->DisplayMemory(40);
mCPU->DisplayMemoryValue( 20 );
// Free everything in the computer.
delete mCPU;
system("pause");
return 0;
}