Question: This program takes in a string of digits, parses it to an int, and computes and returns its factorial in C repeatedly until 0 is

 This program takes in a string of digits, parses it to This program takes in a string of digits, parses it to an int, and computes and returns its factorial in C repeatedly until 0 is entered and the program terminates after returning the factorial of 0 (1). I need to convert it essentially line by line to MIPS, using syscall 8 to read input, then syscall 1 to print the result. code will have one main procedure and two leaf procedures. arguments must be passed to a_to_i and factorial in register $a0, and results should be returned in register $v0.

#include char input [22]; int a_to_i(chark str); int factorial(int n); // To read in a string of up to 20 digits plus newline and null int mainO int fact; int value = 1; while(value !=0){ printf("enter string:") fgets(input, 22, stdin); value a_to_i(input); // print f("%d ", value); fact factorial (value); printf("%d ", fact); return 1; int a to_i(char* str) int result = 0; int i; for (i 0; input [i] != . '; ++i) { - result result * 10 + input [1] - .0'; return result int factorial(int n) int i, f = 1; for(i-1; i

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!