Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MIPS/SPIM programming using the data provided Your program is to print the binar

ID: 3719700 • Letter: M

Question

MIPS/SPIM programming using the data provided

Your program is to print the binary representation of a decimal number using a divide by 2 conversion routine.

1. Use syscall 4 to prompt for a number between -128 and 127 as listed in the data declaration label prompt:

2. Input a number (using syscall 5)

3. If the number is not within the limits, print message at label err: and try again.

4. Convert this decimal number to binary and output its binary representation to the console using divide by 2 method.

4a. Push each remainder on the stack then pop them and print them using syscall 1. A header as listed in the data declaration label ans: should precede that.

4b. The magnitude of the number will always be 8 bits with MSB =1 for negative numbers and 0 for positive numbers.

5. The program will continue prompting for a number as long as y is entered when prompted as listed in the data declaration label newin:

5a. If any other character is entered, the program prints the message at label term: in the data declaration and exits the program.

Hint: The 8-bit binary representation of a negative number m is the same as that of positive number equal to 256 + m.

The beginning of the program and the data declaration are given below

# Program to convert a number between -128 and 127 to its binary equivalent and

# outputs its binary representation to the console.

.text

main:             

.data

prompt:         .asciiz " Input a decimal number between -128 and 127: "

ans:               .asciiz " Binary representation is "

err:                 .asciiz " input error - try again!"

term:             .asciiz " Program terminated"

newin:           .asciiz "Do you want to try another number? (y for yes) "

Explanation / Answer


Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote