-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstruction.cpp
More file actions
57 lines (47 loc) · 877 Bytes
/
instruction.cpp
File metadata and controls
57 lines (47 loc) · 877 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
50
51
52
53
54
55
56
57
#include "stdafx.h"
#include "instruction.h"
instruction::instruction()
{
}
instruction::~instruction()
{
}
void instruction::set_inst(string str){
inst = str;
}
string instruction::get_op_str(){
string str = inst;
for (int i = 0; i < op.size(); i++){
str = str + ' ' + op[i];
}
return str;
}
void instruction::set_op(vector<string> vec){
string str;
for (int i = 0; i < vec.size(); i++){
switch (i){
case 0:
inst = vec[i];
break;
default:
str = vec[i];
if (str[0] == '0' && str[1] == 'x'){
vec[i].erase(vec[i].begin(), vec[i].begin() + 2);
}
op.push_back(vec[i]);
break;
}
}
}
void instruction::insert_op(string str){
if (str[0] == '0' && str[1] == 'x'){
str.erase(str.begin(), str.begin() + 2);
}
op.push_back(str);
}
string instruction::get_inst(){
return inst;
}
vector<string> instruction::get_op(){
return op;
}