Write a MIPS assembly language program that prompts a user for a positive decima
ID: 2072581 • Letter: W
Question
Write a MIPS assembly language program that prompts a user for a positive decimal integer, reads the integer typed by the user and outputs the following values. The total number of 1's in the left half of the binary representation of the integer The total number of 0's in the right half of the binary representation of the integer The highest power of 2 that evenly divides the integer The value of the smallest digit in the decimal representation of the integer. Recall that each integer is represented using 32 bits in MIPS. Suppose the user types the integer 1536. The 32-bit binary representation of 1536 is 0000 0000 0000 0000 0000 0110 0000 0000 The output answer is as follows: The number of 1's in the left half of the binary representation of the given integer = 0 The number of 0's in the right half of the binary representation of the given integer = 14 The largest power of 2 that evenly divides the given integer = 9 (the largest power of 2 that evenly divides 1536 is 9) Program outline: a) Prompt the user for a positive integer. b) Read the integer c) Computer the four quantities mentioned above (1, 2, 3, 4) and print the answers d) Stop. You are to include that when the program is executed only one integer is allowed to be handled.Explanation / Answer
Loop: stli $t0, $s0, 10
beq $t0, $zero, exit
sll $t1, $s0, 2
add $t1, $t1, $s2
add $t2, $s1, $s0
sw $t2, 0($t1)
addi $s0, $s0, 1
j Loop
exit:
Related 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.