Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

I am trying to implement a MIPS assembly code that coverts string to integer. Can you help me implement this algorithm please. Thank you Obeys

image text in transcribedimage text in transcribed

I am trying to implement a MIPS assembly code that coverts string to integer. Can you help me implement this algorithm please.

Thank you

Obeys all applicable MIPS function calling conventions

Takes two arguments: a. First argument: address of a null terminated string b. Second argument: An integer in the range of 2 to 16, inclusive

Returns an integer result The first argument is the address of a sequence of digits, possibly starting with a - (minus) sign.

The function steps through the string of characters (in an appropriate direction) and converts the string to a signed integer value, assuming the integer base value given in the second argument. Negation is to be 2s complement.

You can assume the following:

1) The first argument is a legitimate address, indicating the first character of a string of characters. 2) The string of characters is terminated by a null character \0. This character is not considered part of the string.

3) It is possible the string is empty, that is, the character at the address in the first argument is the null character. In this case, a return value of zero is appropriate.

4) The result will fit into a 32-bit integer

If any character is encountered which is not a legal digit for the base given, print an error message and return a zero result. Bases larger than 10 will use the upper case letters A, B, C, D, E and F as the digits larger that 9. Lower case letters will not be recognized as legal digits.

The string argument may begin with a - sign indicating a negative number. In this case, convert the remaining digits and perform a 2s complement operation before returning the result value. A minus sign is only permitted as the first character of the string. A plus + character is never legal in the string. If the second argument is not in the range of 2 through 16 (inclusive), print an error message and return a zero value.

Write a MIPS assembly language function named (labeled) "stringToInt", with the following characteristics 1) Obeys all applicable MIPS function calling conventions 2) Takes two arguments: First argument: address of a null terminated string Second argument: An integer in the range of 2 to 16, inclusive a. b. 3) Returns an integer result The first argument is the address of a sequence of digits, possibly starting with a "- " (minus) sign. The function steps through the string of characters (in an appropriate direction) and converts the string to a signed integer value, assuming the integer base value given in the second argument. Negation is to be 2's complement. You can assume the following: 1) The first argument is a legitimate address, indicating the first character ofa string of characters 2) The string of characters is terminated by a null character"0". This character is not considered part of the string. 3) It is possible the string is empty, that is, the character at the address in the first argument is the null character. In this case, a return value of zero is appropriate. 4) The result will fit into a 32-bit integer You may NOT assume all the characters in the string are legal with respect to the base argument. That is, you could encounter characters other than 0, 1, 2, 3, 4, 5, 6 and 7 when converting a base 8 number. If any character is encountered which is not a legal digit for the base given, print an error message and return a zero result. Bases larger than 10 will use the upper case letters A, B, C, D, E and F as the digits larger that 9. Lower case letters will not be recognized as legal digits. The string argument may begin with a -"sign indicating a negative number. In this case, convert the remaining digits and perform a 2's complement operation before returning the result value. Aminus sign is only permitted as the first character of the string. A plus "+" character is never legal in the string If the second argument is not in the range of 2 through 16 (inclusive), print an error message and return a zero value. Write a MIPS assembly language function named (labeled) "stringToInt", with the following characteristics 1) Obeys all applicable MIPS function calling conventions 2) Takes two arguments: First argument: address of a null terminated string Second argument: An integer in the range of 2 to 16, inclusive a. b. 3) Returns an integer result The first argument is the address of a sequence of digits, possibly starting with a "- " (minus) sign. The function steps through the string of characters (in an appropriate direction) and converts the string to a signed integer value, assuming the integer base value given in the second argument. Negation is to be 2's complement. You can assume the following: 1) The first argument is a legitimate address, indicating the first character ofa string of characters 2) The string of characters is terminated by a null character"0". This character is not considered part of the string. 3) It is possible the string is empty, that is, the character at the address in the first argument is the null character. In this case, a return value of zero is appropriate. 4) The result will fit into a 32-bit integer You may NOT assume all the characters in the string are legal with respect to the base argument. That is, you could encounter characters other than 0, 1, 2, 3, 4, 5, 6 and 7 when converting a base 8 number. If any character is encountered which is not a legal digit for the base given, print an error message and return a zero result. Bases larger than 10 will use the upper case letters A, B, C, D, E and F as the digits larger that 9. Lower case letters will not be recognized as legal digits. The string argument may begin with a -"sign indicating a negative number. In this case, convert the remaining digits and perform a 2's complement operation before returning the result value. Aminus sign is only permitted as the first character of the string. A plus "+" character is never legal in the string If the second argument is not in the range of 2 through 16 (inclusive), print an error message and return a zero value

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_2

Step: 3

blur-text-image_3

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

More Books

Students explore these related Databases questions

Question

7. General Mills

Answered: 3 weeks ago