(2 bookmarks) /The read_int system call (number 5) will cause the running program to stop and wait for the user to type

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899559
Joined: Mon Aug 02, 2021 8:13 am

(2 bookmarks) /The read_int system call (number 5) will cause the running program to stop and wait for the user to type

Post by answerhappygod »

(2 bookmarks)
/The read_int system call (number 5) will cause the running
program to stop and wait for the user to type in an integer at the
keyboard. The integer will be put into $v0 register and will be
available after the syscall completes. Write a MIPS assembly
language program which prompts for a user to enter four integers
and calls read_int four times to read in four integers. The program
should perform addition, subtraction, multiplication, integer
division, and modulo operation (compute the remainder of their
division) using two of these four integers (see the C program
below), then display their result on the console window. Also
compute (num3 / 4)+((num2 - num4 * num1) % 3) where num1 is the
first read integer, num2 is the second read integer, num3 is the
third read integer, and num4 is the forth read integer, and display
the result.
This is MIPS assembly language. Please tell me where is wrong
with the last part" (num3 / 4)+((num2-num4 * num1) mod3)"

#calculate the long equation
mul $t5, $t4, $t1
sub $t5, $t2, $t5
rem $t5, $t5, 3

div $t5, $t3, 4
add $t5, $t5, $t5
li $v0, 1
move $a0, $t5
syscall
//this will give the wrong answer for the equation (num3 /
4)+((num2-num4 * num1) mod3)


jr $ra

INPUT
----------------
-3
8
-4
-5


----------------
YOUR OUTPUT
----------------
Enter a value:
Enter another value:
Enter one more value:
Enter one more value:
num2+num3=4
num3-num2=-12
num2*num4=-40
num2/num3=-2
num1 mod num4=-3
(num3 / 4)+((num2-num4 * num1) mod3)=?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply