Question

Convert the following C fragment to equivalent MIPS assembly language that calculate and print the absolute...

Convert the following C fragment to equivalent MIPS assembly language that calculate and print the absolute value for any integer input entered
by the user.
The output must be something like:
Enter any integer number: -5
The absolute value is: 5

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>

#include<math.h>

#include<stdlib.h>

int main()

{

int number,result;

printf("enter any value");

scanf("%d",&number);

result=abs(number);

printf("Absolute value of %d = %d\n", number, result);

return 0;

}

/*explanation:-

1.library functions must be used to find absolute value.

2.math.h is the header file which contains abs() function.

3.number is a variable used to store user input.

4.result is a variable used store output value. */

Add a comment
Know the answer?
Add Answer to:
Convert the following C fragment to equivalent MIPS assembly language that calculate and print the absolute...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two...

    Convert the following C fragment to equivalent MIPS assembly language Write mini calculator that take two integer numbers as input and ask the user if he need to compute addition, subtraction, remainder, division, or multiplication then print the result. Hint: you can give each operation a special number. For example, the addition (1), subtraction (2), …. And so on. The output must be something like: Enter the first integer number: 5 Enter the second integer number: 3 Which operation? 1...

  • Convert the following C/C++ fragment into equivalent MIPS assembly language. Assume that the variables a, b,...

    Convert the following C/C++ fragment into equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigned to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. if ((a<b && (c == 0) d = 1;

  • Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b,...

    Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigened to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. Assume that the base address of the array A and B is in register $a0 and $a1 respectively. if (a > 0)            b = a + 10;            else                b = a - 10;

  • Mips assembly language. Ask the user for the quantity of integers that the user would like to ent...

    Mips assembly language. Ask the user for the quantity of integers that the user would like to enter. With each integer entered, a function must be called to store that integer into an array in ascending order. Do not use a sort function. This function will insert the integer into the array in the proper position.

  • Develop an x86 assembly language program that properly executes an absolute value function: int abs(int value)...

    Develop an x86 assembly language program that properly executes an absolute value function: int abs(int value) If the value passed in is negative, the value has its negative sign removed If the value passed in is positive, the value is left alone Remember that the return value must be placed in the EAX register Make sure that any registers (not EAX) used by this function are placed back to their initial states prior to exiting Allow an end user to...

  • Linear Search: Write a MIPS assembly language program that can search for a number that entered...

    Linear Search: Write a MIPS assembly language program that can search for a number that entered by user in an array with 20 integer numbers and prints the index of the number in the array if it is found and -1 if not found

  • MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and...

    MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and print a simple checksum for each string. Make your string long enough to hold 50 characters. Don't forget to leave space for the null byte. Our checksum algorithm will produce a value which you can print with the syscall for printing a character. Stop reading strings when the user enters ".". The syscall to read a string (sycall code 8) adds a newline to...

  • Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence....

    Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)

  • This is a function. PLEASE ANSWER IN MIPS Basic assembly language. No psuedo like li, la,...

    This is a function. PLEASE ANSWER IN MIPS Basic assembly language. No psuedo like li, la, move, etc. Thank you. 2. int readData (&array): The starting address of an array is passed to the function as a parameter using Sa0. The function must prompt for and read and store integers in the array until either a zero is entered or 10 numbers are read. Once the tenth integer is entered, your program must stop reading. The function must return (using...

  • Four Integer Stats Write an ARM Assembly Language (I will not accept Intel Assembly code) program...

    Four Integer Stats Write an ARM Assembly Language (I will not accept Intel Assembly code) program to prompt the user to enter four integers. Have your program output to the screen the four integers that were entered at the keyboard, along with the following: sum of the four integers, smallest value, largest value, and the average of the four values. You must utilize the scanf function for reading in the user input and the printf function for outputting the results...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT