MIPS Write a MIPS program that reads two integers from the keyboard sum them up
ID: 3551602 • Letter: M
Question
MIPS
Write a MIPS program that reads two integers from the keyboard sum them up and print the sum. The first operand must be in register $t0, the second operand must be in register $tl, and the result must be in $t2. Show the contents of the registers. Your input/output should be as follows: (Test your program using one negative operand and where the result sum must be negative). Here is an example. Enter integer: 67 Enter integer: 123 Sum is: 190 Enter integer: 83 Enter integer: -96 Sum is: -13Explanation / Answer
Dear,
.data
prompt1:
.asciiz "Enter integer: "
Output:
.asciiz "Sum: "
main:
li $v0, 4
la $a0, prompt
syscall
li $t0, 5 #read integer
syscall
li $v0, 4
la $a0, prompt
syscall
li $a1, 5 #read integer
syscall
add $t0,$t1 # sum is stored in$ t0
li $v0, 4
la $a0, output
syscall
move $t0, $v0 # return value will be in $v0
li $v0, 1 #print int
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.