4 ; Structured Exception Handling, the Sapphire way
6 ; © 1995-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sapphire library.
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Overview -------------------------------------------------------------
43 ; On entry: R0 == pointer to catch definition block
45 ; On exit: R13 dropped by a (small) amount
47 ; Use: Inserts an exception handler at the current position.
48 ; Exceptions are matched against those described in the catch
49 ; block. If there is a handler for the exception, the
50 ; corresponding handler is called, and expected to resume
51 ; normally. Otherwise the tidy-up routine is called and we
52 ; unwind the stack further to find an appropriate handler.
54 ; The catch block has the following format:
56 ; word B to tidy-up routine
57 ; word 1st exception mask
58 ; word 1st B to catch routine
59 ; word 2nd exception mask
60 ; word 2nd B to catch routine
64 ; An exception mask contains two halfwords. Bits 16-31 are the
65 ; class to match, or -1 for all classes. Bits 0-15 are the
66 ; subtype to match, or -1 for all subtypes. You can do really
67 ; odd things if you set bits 16-31 to -1 and leave 0-15
68 ; matching specific subtypes -- do this at your own risk.
76 ; On exit: R13 moved to position before corresponding seh_try
78 ; Use: Removes the try block marker in the stack at the current
79 ; position. Note that the stack will be unwound to where it
80 ; was when seh_try was called.
86 ; On entry: R0 == exception to match
87 ; R1-R3 == useful bits of information
89 ; On exit: Doesn't return, unless you've done something /really/ odd
91 ; Use: Throws an exception. The stack is unwound until we find
92 ; a handler which can cope. If there is no handler, we abort
97 ; --- seh_throwErrors ---
103 ; Use: Sets up an except-style error handler to throw errors
106 IMPORT seh_throwErrors
108 ; --- seh_setListBase ---
110 ; On entry: R0 == pointer to try block list base, or 0 to use global
114 ; Use: Sets the try block list base. This should only be used by
115 ; coroutine providers, like coRoutine and thread.
117 IMPORT seh_setListBase
125 ; Use: Initialises SEH's facilities.
131 ;----- That's all, folks ----------------------------------------------------