home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / config / m68k-native / exception.s < prev    next >
Encoding:
Text File  |  1996-12-06  |  1.9 KB  |  88 lines

  1. /*
  2.      (C) 1995-96 AROS - The Amiga Replacement OS
  3.      $Id: exception.s,v 1.8 1996/12/06 03:55:43 aros Exp $
  4.  
  5.      Desc:
  6.      Lang:
  7. */
  8.  
  9. /*****************************************************************************
  10.  
  11.     NAME
  12.      AROS_LH0(void, Exception,
  13.  
  14.     LOCATION
  15.      struct ExecBase *, SysBase, 11, Exec)
  16.  
  17.     FUNCTION
  18.      Exception handler. This function is called by the dispatcher if a
  19.      exception has to be delivered. It is called in Disable()d state
  20.      (atomically) so that all Signals are still unchanged.
  21.      TF_EXCEPT is still set and must be reset by this routine.
  22.  
  23.     INPUTS
  24.  
  25.     RESULT
  26.  
  27.     NOTES
  28.      This function has a context on its own and does not need to preserve
  29.      any registers.
  30.  
  31.      Internal exec function.
  32.  
  33.     EXAMPLE
  34.  
  35.     BUGS
  36.  
  37.     SEE ALSO
  38.  
  39.     INTERNALS
  40.  
  41.     HISTORY
  42.  
  43. ******************************************************************************/
  44.  
  45.     #include "machine.i"
  46.  
  47.     .text
  48.     .balign 16
  49.     .globl    AROS_SLIB_ENTRY(Exception,Exec)
  50.     .type    AROS_SLIB_ENTRY(Exception,Exec),@function
  51. AROS_SLIB_ENTRY(Exception,Exec):
  52.     /* First clear task exception bit. */
  53.     move.l    ThisTask(a6),a2
  54.     bclr    #TB_EXCEPT,tc_Flags(a2)
  55.  
  56.     /* If the exception is raised out of a Wait()
  57.        IDNestCnt may be almost everything.
  58.        Store nesting level and set it to a
  59.        defined value 1 beyond -1.
  60.     */
  61. excusr: move.b    IDNestCnt(a6),d2
  62.     clr.b    IDNestCnt(a6)
  63.  
  64. exloop: /* get signals causing the exception (do nothing if there are none) */
  65.     move.l    tc_SigExcept(a2),d0
  66.     and.l    tc_SigRecvd(a2),d0
  67.     beq    excend
  68.  
  69.     /* disable the signals */
  70.     eor.l    d0,tc_SigExcept(a2)
  71.     eor.l    d0,tc_SigRecvd(a2)
  72.  
  73.     /* call the exception vector with interrupts enabled */
  74.     move.l    tc_ExceptData(a2),a1
  75.     move.l    tc_ExceptCode(a2),a0
  76.     jsr    Enable(a6)
  77.     jsr    (a0)
  78.     jsr    Disable(a6)
  79.  
  80.     /* reenable signals and look again */
  81.     or.l    d0,tc_SigExcept(a2)
  82.     bra    exloop
  83.  
  84.     /* restore state of Disable() and return */
  85. excend: move.b    d2,IDNestCnt(a6)
  86.     rts
  87.  
  88.