[net.micro.amiga] Exception handlers and SetExcept

james@uw-atm.UUCP (James M Synge) (09/22/86)

[ come and ge

  I learned a few things this weekend while building an exception handler.

  In the Tasks chapter of the RKM, it says that you should use the routine
SigExcept to adjust the value of tc_SigExcept.  The routine doesn't exist in
the auto docs in volume 2; but there is a routine SetExcept which seems to
be the same thing.  In the man page for SetExcept if gives a very poor
description of the function.  Let me add the following:

    oldSignals = SetExcept(signalValues, signalMask)

  Psuedo-code for the value of tc_SigExcept would look sort of like this:

    tc_SigExcept =
        (signalValues AND signalMask) OR (tc_SigExcept AND (NOT signalMask))

  Thus, signalMask indicates which bits of tc_SigExcept are being effected,
and (signalValues AND signalMask) is the value of those bits.

  To disable all exceptions, use SetExcept(0L, 0xFFFFFFFF).

  To get the current value of tc_SigExcept, use value = SetExcept(0L, 0L).

WARNING:
  The manual states that if you use SetExcept to enable a signal to cause
an exception, and that signal has already been received, then the exception
will occur immediately (before SetExcept returns).  I have found that just
calling SetExcept(signalMask, signalMask), which enables all signals in
signalMask, causes an immediate exception, even though the signal(s) have not
occurred.  I suspect this is a bug, but the manual does not explicitly
dis-allow this.
END WARNING

  One of the side effects of this is that you must install your handler
before you call SetExcept.  I've noticed that there seems to be a default
handler in tc_ExceptCode, but I have no idea why, since tc_SigExcept is 0.
Your handler should be able to handler the case where register d0 is 0, and
not non-zero as one would expect.

James M Synge.
-- 
---------------------------------------------------------------------------
James M Synge, Department of Atmospheric Sciences, University of Washington
VOX: 1 206 543 0308 (Work)   1 206 455 2025 (Home)
UUCP: uw-beaver!geops!uw-atm!james
ARPA: geops!uw-atm!james@beaver.cs.washington.edu