aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/instructions/jumpbranch.cpp
blob: 2ede399cdbb8862c65c13bbf3ae0a3018b6ecce6 (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
#include "jumpbranch.h"

InstructionJump::InstructionJump(bool link, std::uint32_t address)
    : InstructionJ(address) {
    this->link = link;
}

std::vector<std::string> InstructionJump::to_strs() {
    std::vector<std::string> str = this->InstructionJ::to_strs();
    if (link)
        str[0] = "j";
    else
        str[0] = "jal";
    return str;
}

InstructionJumpRegister::InstructionJumpRegister(bool link, std::uint8_t rs)
    : InstructionR(rs, 0, 0, 0) {
    this->link = link;
}

std::vector<std::string> InstructionJumpRegister::to_strs() {
    std::vector<std::string> str = this->InstructionR::to_strs();
    str.erase(str.begin() + 2, str.end()); // Drop every field after rs
    if (link)
        str[0] = "j";
    else
        str[0] = "jal";
    return str;
}