-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp.cpp
64 lines (46 loc) · 2.2 KB
/
exp.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
#include <bits/stdc++.h>
using namespace std;
const map<unsigned, pair<unsigned, string> > decoder = { {0, {1, "ldc"}},
{1, {1, "adc"}},
{2, {1, "ldl"}},
{3, {1, "stl"}},
{4, {1, "ldnl"}},
{5, {1, "stnl"}},
{6, {0, "add"}},
{7, {0, "sub"}},
{8, {0, "shl"}},
{9, {0, "shr"}},
{10, {1, "adj"}},
{11, {0, "a2sp"}},
{12, {0, "sp2a"}},
{13, {1, "call"}},
{14, {0, "return"}},
{15, {1, "brz"}},
{16, {1, "brlz"}},
{17, {1, "br"}},
{18, {0, "HALT"}}
};
string reverse_decode(unsigned a)
{
unsigned opcode = (a<<24)>>24;
ostringstream oss;
map<unsigned, pair<unsigned, string> >::const_iterator mt = decoder.find(opcode);
string mnemonic = mt->second.second; // storing the mnemonic
oss<<mnemonic;
if(mt->second.first==1) // operand also present
{
int tmp = a & 0xffffff00;
tmp /= 256;
oss<<" "<<tmp;
}
return oss.str();
}
int main()
{
unsigned long long int a = 0;
a++;
while(a!=0)
++a;
cout<<a-1<<endl;
return 0;
}