-
Notifications
You must be signed in to change notification settings - Fork 0
/
mips3_branch.h
106 lines (89 loc) · 2.06 KB
/
mips3_branch.h
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
#ifndef MIPS3_BRANCH
#define MIPS3_BRANCH
#include "mips3.h"
#include "mipsdef.h"
#include "memory.h"
namespace mips
{
inline void mips3::J(uint32_t opcode)
{
m_next_pc = (m_state.pc & 0xF0000000) | (TARGET << 2);
m_delay_slot = true;
}
inline void mips3::JR(uint32_t opcode)
{
m_next_pc = (uint32_t)RS;
m_delay_slot = true;
}
inline void mips3::JAL(uint32_t opcode)
{
m_next_pc = (m_state.pc & 0xF0000000) | (TARGET << 2);
m_delay_slot = true;
m_state.r[LR] = (int32_t)(m_state.pc + 4);
}
inline void mips3::JALR(uint32_t opcode)
{
m_next_pc = (uint32_t)RS;
m_delay_slot = true;
m_state.r[LR] = (int32_t)(m_state.pc + 4);
}
inline void mips3::BLTZ(uint32_t opcode)
{
if ((int64_t)RS < 0) {
m_next_pc = m_state.pc + ((int32_t)(SIMM) << 2);
m_delay_slot = true;
}
}
inline void mips3::BLTZAL(uint32_t opcode)
{
if ((int64_t)RS < 0) {
m_next_pc = m_state.pc + ((int32_t)(SIMM) << 2);
m_delay_slot = true;
m_state.r[LR] = (int32_t)(m_state.pc + 4);
}
}
inline void mips3::BGEZ(uint32_t opcode)
{
if ((int64_t)RS >= 0) {
m_next_pc = m_state.pc + ((int32_t)(SIMM) << 2);
m_delay_slot = true;
}
}
inline void mips3::BGEZAL(uint32_t opcode)
{
if ((int64_t)RS >= 0) {
m_next_pc = m_state.pc + ((int32_t)(SIMM) << 2);
m_delay_slot = true;
m_state.r[LR] = (int32_t)(m_state.pc + 4);
}
}
inline void mips3::BEQ(uint32_t opcode)
{
if (RS == RT) {
m_next_pc = m_state.pc + ((int32_t)(SIMM) << 2);
m_delay_slot = true;
}
}
inline void mips3::BNE(uint32_t opcode)
{
if (RS != RT) {
m_next_pc = m_state.pc + ((int32_t)(SIMM) << 2);
m_delay_slot = true;
}
}
inline void mips3::BLEZ(uint32_t opcode)
{
if ((int64_t)RS <= 0) {
m_next_pc = m_state.pc + ((int32_t)(SIMM) << 2);
m_delay_slot = true;
}
}
inline void mips3::BGTZ(uint32_t opcode)
{
if ((int64_t)RS > 0) {
m_next_pc = m_state.pc + ((int32_t)(SIMM) << 2);
m_delay_slot = true;
}
}
}
#endif // MIPS3_BRANCH