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

Write a complete MIPS-32 assembly language program including data declaration th

ID: 3823808 • Letter: W

Question

Write a complete MIPS-32 assembly language program including data declaration that uses a function “Eval_Z” which evaluates the following expression Z = X - 3 (Y / 8 + 125). Assume that caller program passes the values of X and Y to the function using registers $a0 and $a1 respectively while the result of executing the function is returned to the caller in register $v0. The caller program should display the result on the console preceded by an appropriate message. Test your program using the following values (X1, Y1) = (100, 24) and (X1, Y1) = (100, 21)

Explanation / Answer

MIPS CODE:-

    .data
   msg .asciiz "The evaluated value of Z is "
   X: .word 100
   Y: .word 24  

   .text
main:
   lw $a0,X
   lw $a1,Y

   jal Eval_Z

   move $s0,$v0

   li $v0,4
   la $a0,msg
   syscall

   li $v0,1
   move $a0,$s0
   syscall

Eval_Z:
   li $t6,8          
   move $t5,$a1
   move $t4,$a0
   div $t5,$t6
   mflo $t5
   addi $t5,$t5,125
   mult $t5,3
   mflo $t5
   sub $t1,$t4,$t5
   move $v0,$t1
   jr $ra
   

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