% spim -notrap -file quiz_exception.s
Below is the code (line numbers to the left are not part of the code). Here is the source of the above code without line numbers: quiz_exception.s
1 # Program for Take-home Quiz: Exception Handling 2 main: la $t1, Data 3 lw $t4, 0($t1) 4 li $v0, 1 # syscall 4 (print_int) 5 add $a0, $0, $t4 6 syscall 7 add $t5, $0, $0 8 lw $t6, 0($t5) 9 li $v0, 4 # syscall 4 (print_str) 10 la $a0, All # print "That's all!" 11 syscall 12 jr $ra # return from main 13 .data 14 Data: .word 314159265 15 All: .asciiz "\nTh-th-th-that's all folkes!\n" 16 ############# Start of Trap Handler ###################### 17 .kdata 18 Duhh: .asciiz "\nDuhh-hhhhh!\n" 19 .ktext 0x80000080 20 li $v0 4 # syscall 4 (print_str) 21 la $a0 Duhh # print "Duhh-hhhhh!" 22 syscall 23 mfc0 $k0 $14 24 rfe 25 addiu $k0 $k0 4 26 jr $k0 27 # Standard startup code. Invoke the routine main with no arguments. 28 .text 29 .globl __start 30 __start: jal main # start up main 31 li $v0 10 32 syscall # syscall 10 (exit)Questions:
# Program for Review Quiz: Exception Handling main: la $t1, Data lw $t4, 0($t1) li $v0, 1 # syscall 4 (print_int) add $a0, $0, $t4 syscall add $t5, $0, $0 lw $t6, 0($t5) li $v0, 4 # syscall 4 (print_str) la $a0, All # print "That's all!" syscall jr $ra # return from main .data Data: .word 314159265 All: .asciiz "\nTh-th-th-that's all folkes!\n"