Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 [09, az]. 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. ", convert2dec(str,X)); 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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Explain strong and weak atoms with examples.

Answered: 1 week ago

Question

Explain the alkaline nature of aqueous solution of making soda.

Answered: 1 week ago

Question

Comment on the pH value of lattice solutions of salts.

Answered: 1 week ago