blob: a6204366828533df55fe4fd6a93d874fb1350309 (
plain)
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
|
#include "instructions/arithmetic.h"
InstructionArithmetic::InstructionArithmetic(enum InstructionArithmeticT type, std::uint8_t rs, std::uint8_t rd, std::uint8_t rt)
: InstructionR(rs, rd, rt, 0) {
this->type = type;
}
QVector<QString> InstructionArithmetic::to_strs() {
QVector<QString> str = this->InstructionR::to_strs();
str.erase(str.begin() + 4); // Drop sa field
switch (this->type) {
case IAT_ADD:
str[0] = "add";
break;
case IAT_ADDU:
str[0] = "addu";
break;
case IAT_SUB:
str[0] = "sub";
break;
case IAT_SUBU:
str[0] = "subu";
break;
case IAT_AND:
str[0] = "and";
break;
case IAT_OR:
str[0] = "or";
break;
case IAT_XOR:
str[0] = "xor";
break;
case IAT_NOR:
str[0] = "nor";
break;
case IAT_SLT:
str[0] = "slt";
break;
case IAT_SLTU:
str[0] = "sltu";
break;
default:
// TODO different exception
throw std::exception();
}
return str;
}
InstructionArithmeticImmediate::InstructionArithmeticImmediate(enum InstructionArithmeticImmediateT type, std::uint8_t rs, std::uint8_t rt, std::uint16_t value)
: InstructionI(rs, rt, value) {
this->type = type;
}
QVector<QString> InstructionArithmeticImmediate::to_strs() {
QVector<QString> str = this->InstructionI::to_strs();
switch (this->type) {
case IAT_ADDI:
str[0] = "addi";
break;
case IAT_ADDIU:
str[0] = "addiu";
break;
case IAT_ANDI:
str[0] = "andi";
break;
case IAT_ORI:
str[0] = "ori";
break;
case IAT_XORI:
str[0] = "xori";
break;
case IAT_SLTI:
str[0] = "slti";
break;
case IAT_SLTIU:
str[0] = "sltiu";
break;
case IAT_LUI:
str[0] = "lu";
break;
default:
// TODO different exception
throw std::exception();
}
return str;
}
|