42.3k views
3 votes
Answer should be in MIPS please! Please ensure you are following the directions. Thank you in advanced!Your program should be able to take one integer values from user input until you enter 0 and program should end if user types in an integer 0. (The prompt should be Enter an integer: )

- Store the integer into $t5 and multiply the number by 8 using shift operations (Do not use multiplication). And then print the values of bit number 6 to 10 of $t5. (The rightmost bit is bit 0) - You need give detail comments to explain what is happening in the code. The level of detail will be graded.
- You need to show the result screens for at least five pairs of numbers including negative numbers.
- You need to use the newlines spaces properly so that the output prints in orderly manner. Your output should look like:
The number you entered:
After it is multiplied by 8:
The bits [6-10] are: (there should be one space between each bit value)
Please Note:
The program first receives user input (integer) and stores it in $t0.
Print the entered number (decimal value)
Multiply the number in $t0 and print the number (decimal value)
Print the value of Bit #6, 7, 8, 9, and 10 of $t5. (The output should look like: 0 1 1 0 0 )

User Maurizio
by
7.9k points

1 Answer

4 votes

Final answer:

The MIPS program takes an integer from user input, multiplies it by 8 using shift operations, and then outputs the values of bits 6 to 10 of the result. The program repeats this process until the user inputs 0, at which point it terminates.

Step-by-step explanation:

This MIPS assembly language program will prompt the user to enter an integer, store the input in a register, and perform certain operations, including shifting and bit extraction. The user input is stored in register $t0. The program then uses a left shift operation to multiply the value by 8, storing the result in $t5. It also extracts and prints the values of bits 6 to 10 of $t5. The loop continues until a 0 is inputted by the user, at which point the program terminates.

To achieve the task, the program uses system calls for input and output, left shift operations instead of multiplication to multiply by 8, and bitwise operations to extract the desired bits from the register. Printing format is maintained to display the output in a comprehensible way.

The emphasis on shift operations and bit manipulation showcases the efficiency and direct control over hardware that is typical in assembly language programming.

User Sam Routledge
by
8.5k points