aboutsummaryrefslogtreecommitdiff
path: root/qtmips_machine/instructions/jumpbranch.cpp
blob: 6579c2bbe726a4268bad6170d9fa5c4746f82a65 (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;
}

QVector<QString> InstructionJump::to_strs() {
    QVector<QString> 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;
}

QVector<QString> InstructionJumpRegister::to_strs() {
    QVector<QString> 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;
}