-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvmtest.cpp
More file actions
50 lines (44 loc) · 933 Bytes
/
vmtest.cpp
File metadata and controls
50 lines (44 loc) · 933 Bytes
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
// vmtest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "../VMEngine/machine.h"
#include "../VMEngine/Assembler.h"
#include "../VMEngine/Data.h"
#include <fstream>
using namespace vm;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
Machine machine;
Assembler assem;
std::ifstream strm;
strm.open("prog.asm");
if (strm.is_open() == false)
{
std::cout << "Cannot open file" << std::endl;
return 1;
}
try
{
assem.Assemble(machine, strm);
}
catch (std::exception& ex)
{
std::cout << ex.what() << std::endl;
return 1;
}
while (machine.IsHalted() == false)
{
try
{
//machine.DumpMachine(std::cout);
machine.Clock();
}
catch (std::exception& ex)
{
std::cout << ex.what() << std::endl;
return 1;
}
}
return 0;
}