Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # proj5.asm
- #
- # Written by: Justin and Victor
- #
- #
- # Demonstrate how the mips cpu handles an exception and its return
- #
- # Notes:
- # 1. Command: xspim -noexception proj5.asm
- # 2. You must use the label __start
- .globl __start
- .data
- bignum: .word 0x40000000
- String: .space 9
- exaddr: .asciiz "\nException at 0x"
- exnum: .asciiz "\n Exception number: "
- nl: .asciiz "\n"
- # exception handler must be in kernel space at this exact address
- .ktext 0x80000180
- # do whatever and then return control to program
- exception_handler:
- # analyze program and then
- # fix $t9 for programmer
- # in this case, programmer had one extra zero in bignum
- # ...
- # move EPC into a register (shown as an example of mfc0 use)
- la $a0, exaddr
- li $v0, 4
- syscall
- mfc0 $s1, $14
- add $v0, $s1, $0
- la $a0, String
- jal h2a
- li $v0, 4
- syscall
- la $a0, exnum
- syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement