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

Need a writing program in Mars Mips. The program should begin by loading the con

ID: 669320 • Letter: N

Question

Need a writing program in Mars Mips.

The program should begin by loading the contents of four integer operands (A, B, C, and D) from memory into registers. Next, the program should use the shift and rotate instructions (sll, srl, sra, rol, ror) to multiply the value of A by 10, divide the value of B by 8 (truncating the result), shift the value of C to the right 6 bit places (writing 0s into the most significant bits of the register), and rotate the value of D 4 bit places to the left. Lastly, your program should write the new values of A, B, C, and D back to memory. Test the program carefully, using both positive and negative integers for inputs. Validate correct program operation by examining the updated contents of the memory operands. (HINT: 10A = 8A + 2A!)

Explanation / Answer

# assuming Address of A is 1234, B is 1238, C is 1242, D is 1246

li $t0, 1234

lw $t1, ($t0) # storing value at A into $t1

sll $t2, $t1, 3 # multiplying A with 8 and storing it in $t2

sll $t3, $t1, 1 # multiplying A with 2 and storing it in $t3

add $t1, $t2, $t3 # adding $t2 and $t3 to get 10A and storing it in $t1

sw $t1, ($t0) # storing the 10A result back in memory

lw $t1, 4($t0) # Loading B value into $t1

sra $t1, $t1, 3 # divide B by 8

sw $t1, 4($t0) # storing the result back in memory

lw $t1, 8($t0) # Loading C value into $t1

srl $t1, $t1, 6 # shift right by 6 bits

sw $t1, 8($t0) # storing the result back in memory

lw $t1, 12($t0) # Loading D value into $t1

sll $t1, $t1, 4 # shift left by 4 bits

sw $t1, 12($t0) # storing the result back in memory

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