home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / internal / m68k / exception.s < prev    next >
Encoding:
Text File  |  1996-07-16  |  1.7 KB  |  87 lines

  1. |*****************************************************************************
  2. |
  3. |   NAME
  4. |
  5. |    void Exception (
  6. |
  7. |   SYNOPSIS
  8. |    void)
  9. |
  10. |   FUNCTION
  11. |    Exception handler. This function is called by the dispatcher if a
  12. |    exception has to be delivered. It is called in Disable()d state
  13. |    (atomically) so that all Signals are still unchanged.
  14. |    TF_EXCEPT is still set and must be reset by this routine.
  15. |
  16. |   INPUTS
  17. |
  18. |   RESULT
  19. |
  20. |   NOTES
  21. |    This function has a context on its own and doesn't need to preserve
  22. |    any registers.
  23. |
  24. |    Internal exec function.
  25. |
  26. |   EXAMPLE
  27. |
  28. |   BUGS
  29. |
  30. |   SEE ALSO
  31. |
  32. |   INTERNALS
  33. |
  34. |   HISTORY
  35. |
  36. |******************************************************************************
  37.  
  38.     Disable     =    -0x78
  39.     Enable        =    -0x7e
  40.     ThisTask    =    0x114
  41.     IDNestCnt   =    0x126
  42.     tc_Flags    =    0xe
  43.     tc_SigRecvd =    0x1a
  44.     tc_SigExcept=    0x1e
  45.     tc_ExceptData=    0x26
  46.     tc_ExceptCode=    0x2a
  47.     TB_EXCEPT   =    5
  48.  
  49.     .globl    _Exec_Exception
  50. _Exec_Exception:
  51.     | First clear task exception bit.
  52.     movel    a6@(ThisTask),a2
  53.     bclr    #TB_EXCEPT,a2@(tc_Flags)
  54.  
  55.     | If the exception is raised out of a Wait()
  56.     | IDNestCnt may be almost everything.
  57.     | Store nesting level and set it to a
  58.     | defined value 1 beyond -1.
  59. excusr: moveb    a6@(IDNestCnt),d2
  60.     clrb    a6@(IDNestCnt)
  61.  
  62. exloop: | get signals causing the exception
  63.     | (do nothing if there are none)
  64.     movel    a2@(tc_SigExcept),d0
  65.     andl    a2@(tc_SigRecvd),d0
  66.     jeq    excend
  67.  
  68.     | disable the signals
  69.     eorl    d0,a2@(tc_SigExcept)
  70.     eorl    d0,a2@(tc_SigRecvd)
  71.  
  72.     | call the exception vector with interrupts enabled
  73.     movel    a2@(tc_ExceptData),a1
  74.     movel    a2@(tc_ExceptCode),a0
  75.     jsr    a6@(Enable)
  76.     jsr    a0@
  77.     jsr    a6@(Disable)
  78.  
  79.     | reenable signals and look again
  80.     orl    d0,a2@(tc_SigExcept)
  81.     jra    exloop
  82.  
  83.     | restore state of Disable() and return
  84. excend: moveb    d2,a6@(IDNestCnt)
  85.     rts
  86.  
  87.