Question: code this algorithm in mips assembler language Algorithm 3: // read one line of text // output each word of the input line, first all

code this algorithm in mips assembler language Algorithm 3: // read onecode this algorithm in mips assembler language

Algorithm 3: // read one line of text // output each word of the input line, first all words from the end, // the second time from the beginning of the line. Example: // hello world Il results in // world // hello // hello // world #include struct char terminator; // set to 0 and never changed again char line[80]; // input line } buffer: // output a text from here to here void out(char "from_here, char "to_here) { while (from_here printf(" "); // use writecrlf > // search from buffer for the next occurrence of c with given search direction char "span(char "buffer, char e, int direction) { while ("buffer=c) { if ("buffer0) return buffer: buffer += direction: } return buffer: > // return the words of the input line void rueckwaerts(char "buffer) { Il end = pointer to last character of line char Wend-buffer; while (*end!=0) end++; if (enda-buffer) return; end Il over all words char do tempespan(end,',-1); // ... search word boundary out(temp+1, end); // ... output word end-temp-1; // ... move on while (temp!-0): } "temp: // output words of the input line ahead void vorwaerts(char *buffer) { // buffer is used as local var: first pointer to first character if ("buffer=0) return; Il over all words char *temp: do temp-span(buffer.".+1); // ... determine word boundaries out(buffer, temp-1); // ... output word buffer=temp+1; // ... move on while("temp!=0); > int main(void) { fgets(buffer.line, 80, stdin); // read in a line puffer terminator=0; backward(buffer.line): forward(buffer.line): 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!