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

part 1 through 7 must be done in mips32 thank you (24) CS Dolo-YouTube ..CSCI 20

ID: 3732380 • Letter: P

Question

part 1 through 7 must be done in mips32 thank you

(24) CS Dolo-YouTube ..CSCI 201 l Class profile x / à Proiect2por Secure https:/ piazza resources s amazonas corr op h0cb93d dbu81genp43y Project pdf' NSA ceskeld-AKIAEDNRU4ALKBW6A8E pres-1521362211 welcome, Richard-lac × xM Al Mail- okpala.ichard Project2.pdf 1 13 1) Print the following prompt message Please enter a non-zero natural number less than 32,768 (2) Read an integer from the user (3) Repeat the above process (Step 1 and 2) tive times. (4) Check whether or not all the five integers are larger than 0 and less than 32768. Ifnot, repeat Steps 1 through-4 (5) Call a procedure (subprogram that calculates the result of A+B (C Dx E), where A, B. C, D and E are the five integers entered. The procedure should returm the result Use the appropriate MIPS calling conventions, and the usual order of operations. Nole you need to pass 5 values to the subprogram, but can only pass four of them using the argument registers. The fifth value must be passed using the stack! (6) Print the following message: Where A, B, C, D and E should he replaced hy the integers entered, and X is the value of the expression caleulated at Step 5. (7) Return from main using jr Sra (not using the exit syscal1). The jr should not cause an error, and if it does then your program is not using the stack properly. Part 2 (15 points) m in Part . B 137 AM O Type here to search

Explanation / Answer

Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you

.data
msg: .asciiz "Please enter a non-zero natual number less than 32768: "
ans: .ascii "The value of A + B / (C - D * E) is "
A: .word 0
B: .word 0
C: .word 0
D: .word 0
E: .word 0


.text

readA:
#prompt and read int
li $v0, 4
la $a0, msg
syscall


#read int and store in A
li $v0, 5
syscall


#error check
ble $v0, 0, readA
bge $v0, 32768, readA
sw $v0, A


readB:
#prompt and read int
li $v0, 4
la $a0, msg
syscall


#read int and store in B
li $v0, 5
syscall


#error check
ble $v0, 0, readB
bge $v0, 32768, readB
sw $v0, B


readC:
#prompt and read int
li $v0, 4
la $a0, msg
syscall


#read int and store in C
li $v0, 5
syscall


#error check
ble $v0, 0, readC
bge $v0, 32768, readC
sw $v0, C


readD:
#prompt and read int
li $v0, 4
la $a0, msg
syscall


#read int and store in D
li $v0, 5
syscall


#error check
ble $v0, 0, readD
bge $v0, 32768, readD
sw $v0, D

readE:
#prompt and read int
li $v0, 4
la $a0, msg
syscall


#read int and store in E
li $v0, 5
syscall


#error check
ble $v0, 0, readE
bge $v0, 32768, readE
sw $v0, E

#set up parameters for passing to subprogram
lw $a0, A
lw $a1, B
lw $a2, C
lw $a3, D
#allocate space on stack for 5th parameter
sub $sp,$sp, 4
lw $t0, E
sw $t0, ($sp)

#call the subprogram
jal subprogram

move $t0, $v0 #store the return value into $t0


#display the results
li $v0, 4
la $a0, ans
syscall


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

li $v0, 10
syscall

subprogram:
#get the parameter from stack into $t1
lw $t1, ($sp) #t1 = E

#deallocate space on stack
add $sp, $sp, 4

mul $t1, $a3, $t1 # D * E
sub $t1, $a2, $t1 # t1= C - (D*E)

add $t2, $a0, $a1 #t2 = A + B
div $t2, $t2, $t1 # (A+B) / (C- (D*E))

#store the value in $v0
move $v0, $t2
jr $ra


output
=======
Please enter a non-zero natual number less than 32768: 0
Please enter a non-zero natual number less than 32768: 10
Please enter a non-zero natual number less than 32768: 12
Please enter a non-zero natual number less than 32768: 6
Please enter a non-zero natual number less than 32768: 8
Please enter a non-zero natual number less than 32768: 1
The value of A + B / (C - D * E) is
-11
-- program is finished running --