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

Write a complete MIPS assembly language program that implements the following ps

ID: 3793953 • Letter: W

Question

Write a complete MIPS assembly language program that implements the following pseudocode. program h2 y, in the data section. define global integer variables w z, z function main. sysprintstr "Enter an integer o for W? w SysReadInt() Sys Print Str("Enter an integer 0 for x? SysReadInt Sys Print Str("Enter an integer 0 for y? y SysReadInt C) z 16 (w z) (3 x y mod 7) Sys Print Str Sys Print Int(z) SysErit() end function main end program 2 Miscellaneous program requirements and hints: a. Write the code so its output and behavior would match mine shown below, where user input is in bold: Enter an integer 0 for w? 9 Enter an integer 0 for x? 17 Enter an integer 0 for y -5 4.15 b. Define the four variables w, T, y, and z as words in the .data section. Initialize each to 0.

Explanation / Answer

.text
main:

li $v0, 4      
   la $a0, stringW # load address to print string. Eg:Enter the interger >=0 for w?
    syscall           # syscall to print string

   li $v0, 5            # syscall to read user input
    syscall
  
   sw $v0 w         # store the word 'w' content to the specified address
  
   li $v0, 4
    la $a0, stringX # Eg:Enter the interger >=0 for x?
    syscall
  
   li $v0,5      
    syscall
  
    sw $v0 x          # store the word 'x' content to the specified address
  
   li $v0, 4
    la $a0, stringY # Eg:Enter the interger >=0 for y?
    syscall
  
   li $v0,5      
    syscall
  
    sw $v0 y       # store the word 'y' content to the specified address
  
    li $v0, 4
    la $a0, output # Eg:z=?
    syscall
  
   lw $t0 w        # t0 hold w integer
    lw $t1 x        # t1 hold x integer
   lw $t2 y        # t2 hold y integer
   lw $t5 z       # t5 hold z integer
  
   li $v0 1
    add $t3,$t0,$t1 # add $t0 and $t1 => $t3 = w+x
   mult $3,16        # multiply w+x by 16 => 16(w+x)
  
   div $t2,7            # div $t2 by 7, and LO store integer quotient, HI store the remainder
   mfhi $t4
   mult $t4,3        # multiply $t4 by 3. Eg: (-y mod 3)
  
   sub $t5,$t3,$t4 #subtract $t3 and $t4. Eg: 16(w+x) - (-y mod 3) and sotre it in $a0.
   ld $a0,$t5       # load the output to $a0
    syscall

.data
    stringW: .asciiz "Enter the interger >=0 for w? "
    stringX: .asciiz "Enter the interger >=0 for x? "
   stringY: .asciiz "Enter the interger >=0 for y? "
   output: .asciiz "z="
   w : .word 0
    x : .word 0
   y : .word 0
   z : .word 0   

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