CS 2734
Computer Organization II
In this laboratory you will explore exception handling in MIPS.
instructions.s
program under spim:
spim -file instructions.s
The program
should generate six
Bad Data/Stack Address Exceptions (Exception 7) because
the program assumes that the data segment starts at 0 and
xspim assumes that it starts at 0x10000000.
instructions.s
program again using xspim and this time single step through
at least two exceptions. Make sure you see how the flow of
control is changed by looking at the source code and note where
the exceptions occur.
xspim -file instructions.s
cat instructions.s trap.handler > instr_trap.s
Run xspim using the following command line.
(Don't forget the -notrap option, or Spim will load both
the default handler and the one you concatenated at the end.)
xspim -notrap -file instr_trap.s
You can also try out spim:
spim -notrap -file instr_trap.s
The program should run the same way it did before.
When you run the program you should only get two Exception 7 occurrences at the instructions:
lw $t4, 84($t1) #Constant 4 stored in $t4
....
sw $t3, 0($t1) #sum is stored
Your program should handle these exceptions so that the correct
calculation is performed and a 36 is printed at the end.
addu when adding addresses so that
you don't generate an overflow exception.