-
Notifications
You must be signed in to change notification settings - Fork 2
/
runProgram.cpp
123 lines (119 loc) · 1.46 KB
/
runProgram.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "library.h"
#include "commands.h"
#include "arithmetic.h"
#include "jump.h"
extern int pc;
void runprog(string cmd[],int len )
{
if(cmd[0]=="mvi")
{
mvi(cmd,len);
}
else if(cmd[0]=="mov")
{
mov(cmd,len);
}
else if(cmd[0]=="sta")
{
sta(cmd,len);
}
else if(cmd[0]=="lda")
{
lda(cmd,len);
}
else if(cmd[0]=="inr")
{
inr(cmd,len);
}
else if(cmd[0]=="dcr")
{
dcr(cmd,len);
}
else if(cmd[0]=="lhld")
{
lhld(cmd,len);
}
else if(cmd[0]=="shld")
{
shld(cmd,len);
}
else if(cmd[0]=="lxi")
{
lxi(cmd,len);
}
else if(cmd[0]=="stax")
{
stax(cmd,len);
}
else if(cmd[0]=="xchg")
{
xchg(cmd,len);
}
else if(cmd[0]=="inx")
{
inx(cmd,len);
}
else if(cmd[0]=="dcx")
{
dcx(cmd,len);
}
else if(cmd[0]=="add")
{
add(cmd,len);
}
else if(cmd[0]=="adi")
{
adi(cmd,len);
}
else if(cmd[0]=="sub")
{
sub(cmd,len);
}
else if(cmd[0]=="sui")
{
sui(cmd,len);
}
else if(cmd[0]=="jmp")
{
jmp(cmd,len);
}
else if(cmd[0]=="jnz")
{
jnz(cmd,len);
}
else if(cmd[0]=="jz")
{
jz(cmd,len);
}
else if(cmd[0]=="jnc")
{
jnc(cmd,len);
}
else if(cmd[0]=="jc")
{
jc(cmd,len);
}
else if(cmd[0]=="cmp")
{
cmp(cmd,len);
}
else if(cmd[0]=="dad")
{
dad(cmd,len);
}
else if(cmd[0]=="store")
{
store(cmd,len);
}
else if(cmd[0]=="cma")
{
cma(cmd,len);
}
else if(cmd[0]=="hlt")
{
}
else
{
cout<<"error "<<pc<<" : invalid command"<<endl;
}
}