Write the following C/C++ program that will generate the instruction format for a given MIPS instruction.

Your program will get user input which will be a MIPS instruction and then will print the instruction format on the console. Your program needs to support at least the following MIPS instructions;


The sample execution of your program is shown below;

Enter the MIPS instruction? add $t1, $t1,$s6
Instruction format will be
Opcode: 0
rs register: 9
rt register: 22
rd register: 9
shift amount:0
Function code:32
Enter the MIPS instruction? addi $s3, $s3,-15
Instruction format will be
Opcode: 8
rs register: 19
rt register: 19
immediate value: -15

Enter the MIPS instruction? j Exit1
Enter the memory address of Exit1? 80032
Opcode: 2
Address: 20008
Page 2 of 2
Enter the MIPS instruction? bne $t0, $s6, MyExit1
Enter the current Program Counter (PC) ? 80008
Enter the memory address of MyExit1 ? 80044
Instruction format will be;

Opcode: 5

rs register: 8

rt register: 22

immediate value: 4

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <cstdlib>
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;

const int MAX_AGU = 4;

// trim from start
string <rim(string &s) {
       s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
       return s;

// trim from end
string &rtrim(string &s) {
       s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
       return s;

// trim from both ends
string &trim(string &s) {
       return ltrim(rtrim(s));
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats