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

Create a MIPS program that fulfills the following specifications: • in the .data

ID: 3875354 • Letter: C

Question

Create a MIPS program that fulfills the following specifications: • in the .data section: o 3 variables to hold input values: a, b, c o 3 variables to hold output values o a variable to hold the user’s name o 3 variables for messages: prompt for name prompt for integers message for results (similar to the sample run below) • in the .text section write instructions to: o prompt the user for their name and save it o 3 times: prompt user for an integer between 1-100 read and store the integers in a, b, and c o calculate ans1 = a + b + c and store the result o calculate ans2 = c + b - a and store the result o calculate ans3 = (a + 2) + (b - 5) - (c – 1) and store the result o display the user name and message for results o display the 3 results but print a space character in between for readability • at the bottom of your program, add comments with test values for a, b, c and the results you expect from the program for ans1, ans2, ans3  

Explanation / Answer


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


.data
name: .space 25
a: .word 0
b: .word 0
c: .word 0
ans1: .word 0
ans2: .word 0
ans3: .word 0
prompt1: .asciiz "Enter your name: "
prompt2: .asciiz "Enter an integer between 1-100: "
nameMsg: .asciiz " Your name is "
ans1Msg: .asciiz " a + b + c = "
ans2Msg: .asciiz " c + b - a = "
ans3Msg: .asciiz " (a + 2) + (b - 5) - (c - 1) = "

.text
#prompt and read string
li $v0, 4
la $a0, prompt1
syscall

#read string
li $v0, 8
la $a0, name
li $a1, 25
syscall

#prompt and read int a
li $v0, 4
la $a0, prompt2
syscall


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


#prompt and read int b
li $v0, 4
la $a0, prompt2
syscall


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

#prompt and read int c
li $v0, 4
la $a0, prompt2
syscall


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


#do the calculations

#get the values from memory into registers
lw $t0, a
lw $t1, b
lw $t2, c

#calculate a+b+c
add $t3, $t0, $t1 #a+b in t3
add $t3, $t3, $t2 #a+b+c in t3
sw $t3, ans1 #store result in ans1


#calculate c + b - a
add $t3, $t1, $t2 #c+b in t3
sub $t3, $t3, $t0 #c+b - a in t3
sw $t3, ans2 #store result in ans2


#calculate (a + 2) + (b - 5) - (c – 1)
add $t3, $t0, 2 #a+2 in t3
sub $t4, $t1, 5 #b-5 in t4
sub $t5, $t2, 1 #c-1 in $t5
add $t3, $t3, $t4 #(a+2) + (b-5) in t3
sub $t3, $t3, $t5 #(a+2) + (b-5) - (c-1) in t3
sw $t3, ans3 #store result in ans3


#display the values

#display name
li $v0, 4
la $a0, nameMsg
syscall

li $v0, 4
la $a0, name
syscall

#display ans1
li $v0, 4
la $a0, ans1Msg
syscall

li $v0, 1
lw $a0, ans1
syscall


#display ans2
li $v0, 4
la $a0, ans2Msg
syscall

li $v0, 1
lw $a0, ans2
syscall


#display ans3
li $v0, 4
la $a0, ans3Msg
syscall

li $v0, 1
lw $a0, ans3
syscall


#exit
li $v0, 10
syscall


output


Enter your name: John
Enter an integer between 1-100: 3
Enter an integer between 1-100: 8
Enter an integer between 1-100: 15

Your name is John

a + b + c = 26
c + b - a = 20
(a + 2) + (b - 5) - (c - 1) = -6