-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
88 lines (86 loc) · 2.35 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include<iostream>
using namespace std;
#include "8085_processor.h"
int main()
{
vector<string> s;
cout<<"\n\n\t\t\t\tWelcome to 8085 Emulator\nEnter the Aim of Program : ";
string aim;
getline(cin,aim);
uint16_t x;
cout<<"\n\nEnter Starting Address : ";
cin>>hex>>x;
cin.ignore();
cout<<"\n\nEnter Program :-\n\n";
string temp;
uint16_t t=x;
while(temp!="HLT")
{
cout<<hex<<t<<" : ";
getline(cin,temp);
t+=add::count(temp);
s.push_back(temp);
}
s.pop_back();
char memper;
CPU obj(s,x);
obj.initialize_instruction_table();
cout << "\n\nMenu:\n";
cout << "1. Initialize memory\n";
cout << "2. Set breakpoint\n";
cout << "3. Make subroutine\n";
cout << "4. Continue to Execute\n";
cout << "5. Exit\n\n";
int choice;
do
{
cout<<"\nEnter Further Choice : ";
cin >> choice;
switch (choice) {
case 1:
obj.obj.memory_initializer();
break;
case 2:
uint16_t breakpoint;
do
{
cout << "\nEnter breakpoint address: ";
cin >> hex >> breakpoint;
obj.bp.push(breakpoint);
cout<<"\nWant to add more Breakpoints?\n";
cin>>memper;
} while (memper!='N');
break;
case 3:
do
{
obj.subr_init();
cout<<"\nWant to make more subroutine?\n";
cin>>memper;
} while (memper=='Y');
break;
case 4:break;
case 5:return 0;
default:cout<<"Enter a Valid Choice\n";
}
} while (choice!=4);
obj.execute();
do
{
cout << "\n\nProgram has Executed Successfully : \n";
cout << "1. Display memory\n";
cout << "2. Display CPU state\n";
cout << "3. Exit\n\n";
cin>>choice;
switch(choice)
{
case 1:obj.obj.memory_display();
break;
case 2:obj.CPU_state();
break;
case 3:cout<<"\n\t\t\t\tThank you for using the 8085 Simulator\n\n";
break;
default:cout<<"Enter a Valid Choice\n";
}
} while (choice!=3);
}