Question: build your own assembler that reads the R/I/J Format Instructions of MIPS I-Format (Data transfer, branch format) op rs rt address 6 bits 5 bits

build your own assembler that reads the R/I/J Format Instructions of MIPS

I-Format (Data transfer, branch format)

op rs rt address 6 bits 5 bits 5 bits 16 bits

J-Format (Jump instruction format)

op address 6 bits 26 bits

R-Format (Arithmetic instruction format)

op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits

using the template below:

#include #define MAXLINE 80 #define MAXREG 5 int main() { char line[MAXLINE]={0}; char oper[MAXLINE]; char rd[MAXREG],rs[MAXREG],rt[MAXREG]; while (fgets(line, MAXLINE, stdin)) { /* check if a 3-address R format instruction */ if (sscanf(line, "%s $%[^,],$%[^,],$%s", oper, rd, rs, rt) == 4) { printf("input line: %s ", line); printf("parsed line: op:%10s rd:%5s rs:%5s rt:%5s ", oper, rd, rs, rt); } /* you need to add other patterns for R,I,and J encoding */ else { printf("input line: %s ", line); printf("you need to add sscanf format "); } } return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!