diff options
author | Karel Kočí <cynerd@email.cz> | 2017-08-30 21:37:53 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-08-30 21:42:02 +0200 |
commit | 9cf92379d5fcf0076c25dae0935daab446c992cd (patch) | |
tree | dd09a2e996db1e5a8117f01bec76f1e93eaca6e1 /qtmips_machine/instructions/jumpbranch.cpp | |
download | qtmips-9cf92379d5fcf0076c25dae0935daab446c992cd.tar.gz qtmips-9cf92379d5fcf0076c25dae0935daab446c992cd.tar.bz2 qtmips-9cf92379d5fcf0076c25dae0935daab446c992cd.zip |
Initial commit
Adding work done so far.
Diffstat (limited to 'qtmips_machine/instructions/jumpbranch.cpp')
-rw-r--r-- | qtmips_machine/instructions/jumpbranch.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/qtmips_machine/instructions/jumpbranch.cpp b/qtmips_machine/instructions/jumpbranch.cpp new file mode 100644 index 0000000..2ede399 --- /dev/null +++ b/qtmips_machine/instructions/jumpbranch.cpp @@ -0,0 +1,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; +} |