Write a program to implement the following functions. Some of the credit will in
ID: 3638787 • Letter: W
Question
Write a program to implement the following functions. Some of the credit will include following the MIPS conventional use of registers for function calls. You may take advantage of the fact that main() is the only function that calls any other.int HexToValue( char arr[] );
Given an array of characters as an argument, returns the 32-bit value.
The hexadecimal digits for 10 through 15 will use lowercase letters a-f.
void Decimal( char arr[], int value );
Given a positive value less than 10000, converts the value into a four-digit base-10 string, stored into the given array. Leading zeros are fine (and expected, since that is much simpler to implement).
int main()
The main program is to do the following operations repeatedly:
Input an 8-character hexadecimal value from the keyboard (using syscall 8)
Convert the hexadecimal value into its integer equivalent.
Display that integer value in base 10 (using syscall 1)
Sign-extend the rightmost 16 bits of the value into a 32-bit signed number.
(This can be done with exactly two shift instructions.)
If the value is negative, output a '-' to the screen and negate it.
Convert this value to a decimal string, and then output it (syscall 4).
Repeat all of the above steps until the decimal value displayed is zero.
Explanation / Answer
This program will convert a value to hexadecimal value using a-f lower case from 10-15 #include int main(){ int a,b,d; scanf("%d",&a); d=a/16; b=a%16; if(b=0;b--){ c=a%2; a=a/2; arr[b]=c; } for(b=0;bRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.