Chapter 6: Appendix A- 7 (page 572)
A.7 [5] Using SPIM, write and test a program that reads in three integers and prints out the sum of the largest two of the three. Use the SPIM system calls described on pages A-43 and A-45. You can break ties arbitrarily.
Short Answer
The required code:
.data
Str1: .asciiz
Str2: .asciiz
Str3: .asciiz
.text
main:
la $t0, X lw $s0, 0($t0) addi $t1, $0, 0 li $t1, 0
li $a0,0
loop: bge $t0, 8 End_Loop bgt X($t1), $s0, Set_Max_number bgt X($t2), $s1, Set_Max_number addi $t1, $t1, 4 addi $t0, $t0, 1Set_Max_number: move $s0, X($t1) move $s1, X($t2) j loopEnd_Loop: li $v0, 1 addi $s2, $s0, $s1 li $v0,1
syscall