Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ADD to the below another scan format to parse that reads: Input lines: 1. addu $v0, $zero, $s10 ( with spaces between the source codes)

ADD to the below another scan format to parse that reads:

Input lines:

1. addu $v0, $zero, $s10 ( with spaces between the source codes)

2. J L1

/*

*

* For detailed info regarding fgets, refer manpage at linprog

* % man 3 fgets

*

*/

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to the table in question

Answered: 1 week ago