Write a mips program that will read in a base as an integer


Please write MIPS program that runs in QtSpim (ex: MipsFile.s)

Write a MIPS program that will read in a base (as an integer) and a value (nonnegative integer but as an ASCII string) in that base and print out the decimal value; you must implement a function (which accepts a base and an address for a string as parameters, and returns the value) and call the function from the main program.

The base will be given in decimal and will be between 2 and 36, and the digits for the values will be in set [0...9, a...z]. You can assume that no overflow will occur and the value is valid in the given base.

An example run will be:

Enter a base (between 2 and 36 in decimal): 2

Enter a number in base 2: 101

The value in decimal is: 5

The program needs to be able to test 3 different cases and run in QtSpim like a .s file

here is a c program that shows the functionality

#include #include #include int convert2dec(char *str, int base) { int j, val; val = 0; j = 0; while (str[j] > 13) { if (str[j] > 57) val = val * base + str[j]-87; else val = val * base + str[j] - 48; j++; } return val; } int main(int argc, char *argv[]) { int X; char str[256]; printf("Please the base (in decimal): "); scanf("%d", &X); printf("Please enter a nonnegative number: "); scanf("%s", str); printf("The decimal value is %d.\n", convert2dec(str,X)); return 0; }

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a mips program that will read in a base as an integer
Reference No:- TGS02894642

Expected delivery within 24 Hours