Write a MIPS program that prompts the user to enter two numbers and performs add
ID: 3874227 • Letter: W
Question
Write a MIPS program that prompts the user to enter two numbers and performs addition, subtraction, multiplication, and division on two numbers and output the results. Please write in assembly language and provide comments. Write a MIPS program that prompts the user to enter two numbers and performs addition, subtraction, multiplication, and division on two numbers and output the results. Please write in assembly language and provide comments. Write a MIPS program that prompts the user to enter two numbers and performs addition, subtraction, multiplication, and division on two numbers and output the results. Please write in assembly language and provide comments.Explanation / Answer
#addition
# add2.asm
# Registers used:
# $a - used to hold the first number.
# $b - used to hold the second number.
# $c - used to hold the sum of the $a and $b
#.# Get first number from user, put into $a.
## Get second number from user, put into $b.
add $c, $a, $b # compute the sum.
## Print out $c.
li $v0, 10 # syscall code 10 is for exit.
syscall # make the syscall.
# end of add2.asm.
#multiply
# mul2.asm
# Registers used:
# $a - used to hold the first number.
# $b - used to hold the second number.
# $c - used to hold the multiplication of the $a and $b
#.# Get first number from user, put into $a.
## Get second number from user, put into $b.
mul $c, $a, $b # compute the multiplication.
## Print out $c.
li $v0, 10 # syscall code 10 is for exit.
syscall # make the syscall.
# end of mul2.asm.
#divide
# div2.asm
# Registers used:
# $a - used to hold the first number.
# $b - used to hold the second number.
# $c - used to hold the div of the $a and $b
#.# Get first number from user, put into $a.
## Get second number from user, put into $b.
div $c, $a, $b # compute the sum.
## Print out $c.
li $v0, 10 # syscall code 10 is for exit.
syscall # make the syscall.
# end of div2.asm.
#subraction
# add2.asm
# Registers used:
# $a - used to hold the first number.
# $b - used to hold the second number.
# $c - used to hold the sub of the $a and $b
#.# Get first number from user, put into $a.
## Get second number from user, put into $b.
sub $c, $a, $b # compute the sub.
## Print out $c.
li $v0, 10 # syscall code 10 is for exit.
syscall # make the syscall.
# end of sub2.asm.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.