Question: I ' m struggling to finish this program because I can't get it to print the bits. Every time I try, it gives me an
Im struggling to finish this program because I can't get it to print the bits. Every time I try, it gives me an error. I need assistance in making the program print the bits as per the instructions. Below is my current code along with the instructions and the program's current output..dataprompt: asciiz "Enter a number enter to exit: # Prompt for user inputoutput: asciiz "The number you entered: # Output labelmultiplied: asciiz "After it is multiplied by : # Multiplication labelbitslabel: asciiz "The bits are: # Label for printing bitsnewline: asciiz
# Newline character.textmain: # Infinite loop to keep asking the user for inputmainloop: # Print prompt to enter a number li $v # Load syscall code for printing string la $a prompt # Load address of prompt string syscall # Print prompt # Read integer input from the user li $v # Load syscall code for reading integer syscall # Read integer move $t $v # Store the input number in $t # Exit loop if input is beqz $t exit # Exit loop if otherwise continue # Print the entered number li $v # Load syscall code for printing string la $a output # Load address of output string syscall # Print output label li $v # Load syscall code for printing integer move $a $t # Load the integer to be printed syscall # Print entered number # Print newline character li $v # Load syscall code for printing string la $a newline # Load address of newline character syscall # Print newline # Print label for multiplication result li $v # Load syscall code for printing string la $a multiplied # Load address of multiplication label syscall # Print multiplication label # Multiply the number by using shift operations sll $t $t # Shift left by bits multiply by # Print the multiplied number li $v # Load syscall code for printing integer move $a $t # Load the multiplied number to be printed syscall # Print multiplied number # Print newline character li $v # Load syscall code for printing string la $a newline # Load address of newline character syscall # Print newline # Print label for bits li $v # Load syscall code for printing string la $a bitslabel # Load address of bits label syscall # Print bits label # Print bits of the number with space between each bit li $t # Initialize counter to bit #printbitsloop: addi $t $t # Decrement counter bgez $t loopend # Exit loop if counter is not negative bit # printed andi $t $t # Mask out all bits except the rightmost one li $v # Load syscall code for printing integer move $a $t # Load the bit value to be printed syscall # Print the bit value # Print space between bits li $v # Load syscall code for printing string syscall # Print space j printbitsloop # Repeat until all bits are printedloopend: # Print newline character li $v # Load syscall code for printing string la $a newline # Load address of newline character syscall # Print newline j mainloop # Repeat the main loop # Exit the programexit: li $v # Load syscall code for exit syscall # Exit programModify the MIPS program in Example of the textbook page as following:
Your MIPS program should be able to KEEP TAKING integer values from user input until you type in a zero as an input. The program should prompt "Enter a number:" to get the user input. Your program should finish the execution properly when you enter zero as an input.
Store the integer into register $ and print the value. Then, multiply the number by using shift operations Do not use multiplication and print the result.
Print the values of bit number to of $tThe rightmost bit is bit # Bit # should be the first one to be printed You should use the bit manipulation instructions like AND, OR or NOT instruction and you need to use a loop to print the bit values.
You need to give detailed 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 numbers including negative numbers.
You need to use the newlines spaces properly so that the output prints in an orderly manner. Your output should look like:
The number you entered:
After it is multiplied by :
The bits
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
