Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #  proj5.asm
  2. #
  3. #  Written by:  Justin and Victor
  4. #
  5. #
  6. #  Demonstrate how the mips cpu handles an exception and its return
  7. #
  8. #  Notes:
  9. #   1.  Command: xspim -noexception proj5.asm
  10. #   2.  You must use the label __start
  11.  
  12. .globl __start
  13.  
  14. .data
  15. bignum:   .word     0x40000000
  16. String:   .space    9
  17. exaddr:   .asciiz   "\nException at 0x"
  18. exnum:    .asciiz   "\n  Exception number: "
  19. nl:   .asciiz   "\n"
  20.  
  21. # exception handler must be in kernel space at this exact address
  22. .ktext 0x80000180
  23.  
  24. # do whatever and then return control to program
  25. exception_handler:
  26.  
  27. # analyze program and then
  28. # fix $t9 for programmer
  29. # in this case, programmer had one extra zero in bignum
  30. # ...
  31. # move EPC into a register (shown as an example of mfc0 use)
  32.   la   $a0, exaddr
  33.   li   $v0, 4
  34.   syscall
  35.   mfc0 $s1, $14
  36.   add  $v0, $s1, $0
  37.   la   $a0, String
  38.   jal  h2a
  39.   li   $v0, 4
  40.   syscall
  41.   la $a0, exnum
  42.   syscall
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement