|
CS 2733/2731 Computer Organization II Fall 2004 Take-home Quiz: Exceptions Due (on time): 2004-11-29 In class Due (late): 2004-12-01 In class |
1 # Program for Review Quiz: With Exception Handler
2 main: la $t1, Data
3 lw $t4, 0($t1)
4 li $v0, 1 # syscall 1 (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
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 Exception Handler ######################
17 .kdata
18 Inside: .asciiz " Inside local exception handler\n"
19 .ktext 0x80000180
20 li $v0 4 # syscall 4 (print_str)
21 la $a0 Inside
22 syscall
23
24 mfc0 $k0 $14
25 addiu $k0 $k0 4
26 mtc0 $k0 $14
27 eret
28 # Standard startup code. Invoke the routine main with no arguments.
29 .text
30 .globl __start
31 __start: jal main # start up main
32 li $v0 10
33 syscall # syscall 10 (exit)
|
% spim -file without_exception_handler.s
This code is given below and in without_exception_handler.s. Give the line number of the instruction that causes the exception.
1 # Program for Review Quiz: With Exception Handler
2 main: la $t1, Data
3 lw $t4, 0($t1)
4 li $v0, 1 # syscall 1 (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
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"
|
% spim -notrap -file with_exception_handler.s
Starting with line 2, describe exactly what is printed when this code segment executes lines 2 through 12, including possible detours into the code for the exception handler. Will Inside local exception handler be printed and if so, when and why?