-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
64 lines (54 loc) · 1.12 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
//
// main.cpp
// AssemblyProject
//
// Created by Ingy on 3/24/15.
// Copyright (c) 2015 Ingy. All rights reserved.
//
#include <iostream>
#include "Simulator.h"
using namespace std;
int main(int argc, const char * argv[])
{
if(argc>3)
{
cout <<"Error: too many arguments"<<endl;
}
else if(argc==3)
{
// name and textFile and Memory
Simulator S;
if (S.readTextFromFile(argv[1]))
{
if(S.readMemoryFromFile(argv[2]))
S.run();
}
}
else if(argc==2)
{
// name and textFile
Simulator S;
string s="";
if(S.readTextFromFile(argv[1]))
{
S.readMemoryFromFile(s);
S.run();
}
}
else if (argc==1)
{
cout << "Error: too few arguments"<<endl;
string s="";
Simulator S;
if(S.readTextFromFile(s))
{
S.readMemoryFromFile(s);
S.run();
}
else
{
cout <<"\n\nError invalid file\n"<<endl;
}
}
return 0;
}