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: 3879663 • 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 o prompt the user for their name and save it 3 times: prompt user for an integer between 1-100 read and store the integers in a, b, and c - - calculate ans 1 = a + b + c and store the result calculate ans2 = c + b-a and store the result 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 (see sample ruin below) »

Explanation / Answer

Note: I've changed b to b1 as b relates to branch instruction in MIPS

.data

a: .space 4

b1: .space 4

c: .space 4

ans1: .space 4

ans2: .space 4

ans3: .space 4

name: .space 30

prompt_name: .asciiz "Please enter your name: "

prompt_int: .asciiz "Enter a number between 1-100: "

prompt_result: "The final results are: "

space: .asciiz " "

newline: .asciiz " "

.globl main

.text

main:

#prompt user for name

li $v0, 4

la $a0, prompt_name

syscall

#read input from user. Limited to 30 chars

li $v0, 8

la $a0, name

li $a1, 30

move $t0, $a0

syscall

#prompt user for integer and store in a

li $v0, 4

la $a0, prompt_int

syscall

li $v0, 5

syscall

sw $v0, a

#prompt user for integer and store in b

li $v0, 4

la $a0, prompt_int

syscall

li $v0, 5

syscall

sw $v0, b1

#prompt user for integer and store in c

li $v0, 4

la $a0, prompt_int

syscall

li $v0, 5

syscall

sw $v0, c

#load them into temporary variables

lw $t0, a

lw $t1, b1

lw $t2, c

#calculate ans1

add $s0, $t0, $t1

add $s0, $s0, $t2

sw $s0, ans1

#calculate ans2

add $s0, $t1, $t2

sub $s0, $s0, $t0

sw $s0, ans2

#calculate ans3

add $t0, $t0, 2

sub $t1, $t1, 5

sub $t2, $t2, 1

add $s0, $t0, $t1

sub $s0, $s0, $t2

sw $s0, ans3

#print name and newline

li $v0, 4

la $a0, name

syscall

li $v0, 4

la $a0, newline

syscall

#print prompt for result

li $v0, 4

la $a0, prompt_result

syscall

#print answers and space

li $v0, 1

lw $a0, ans1

syscall

li $v0, 4

la $a0, space

syscall

li $v0, 1

lw $a0, ans2

syscall

li $v0, 4

la $a0, space

syscall

li $v0, 1

lw $a0, ans3

syscall

li $v0, 4

la $a0, newline

syscall

#exit using syscall

li $v0, 10

syscall

###############################################

# a = 15, b = 40, c = 60

# ans1 = 115 ans2 = 85 ans3 = -7

# a = 19, b = 23, c = 28

# ans1 = 70 ans2 = 32 ans3 = 12

###############################################

Hope this helps. Do Upvote! :)