[comp.sys.amiga.tech] Modula Floating Point Trapping

black@beno.CSS.GOV (Mike Black) (10/07/90)

Has anyone got an example of how to install trap handlers in Modula?
Specifically, divide-by-zero errors would be REAL nice to handle
yourself.  Any help would be REALLY APPRECIATED!!
Mike...
--
-------------------------------------------------------------------------------
: usenet: black@beno.CSS.GOV   :  land line: 407-494-5853  : I want a computer:
: real home: Melbourne, FL     :  home line: 407-242-8619  : that does it all!:
-------------------------------------------------------------------------------

tmb@davinci.acc.Virginia.EDU (Thomas M. Breeden) (10/09/90)

In article <49138@seismo.CSS.GOV> black@beno.CSS.GOV (Mike Black) writes:
>Has anyone got an example of how to install trap handlers in Modula?
>Specifically, divide-by-zero errors would be REAL nice to handle
>yourself.  Any help would be REALLY APPRECIATED!!
>Mike...
>--
>-------------------------------------------------------------------------------
>: usenet: black@beno.CSS.GOV   :  land line: 407-494-5853  : I want a computer:
>: real home: Melbourne, FL     :  home line: 407-242-8619  : that does it all!:
>-------------------------------------------------------------------------------

Please post if you get some good mail on this.

Replacing the .tcTrap field in the task structure is the first thing to do.
Note that you must replace the previous value back into it (at least if
you are running under the CLI).

Recovery in the context of your running M2 program is something that really
should be a vendor-supplied feature, since that relies on compiler code
generation and run-time architecture decisions.

For the Benchmark Amiga M2 compiler, a module RunTimeErrors is supplied
that allows you to install a type of trap handling (which also needs to
be removed before program end). This trap handler will display a small
window with some info on the trap and give the user the option of exiting
the program or continuing anyway, or invoking the previous trap handler.

Some of the original ETH M2 compilers included a module "Exceptions" that
supported a controlled exception recovery in the form of a proc call format
such that the PROC would return either when finished or when an exception
occurred. (Does anyone know whether the M2 standards activity has touched
on that at all?). Anyway, for Benchmark, if you want to pursue this further,
I can give you a copy of an Exceptions module that "works" on their
current compiler (ie, "works" = "not heavily tested, not guarenteed, not
a good solution without vendor support, but I use it").

Tom Breeden
tmb@virginia.edu  -->> Internet
tmb@virginia      -->> BITNET