[comp.sys.amiga.programmer] 68000 Exceptions

phil@adam.adelaide.edu.au (Phil Kernick) (06/07/91)

What does KS1.3 do when the 680[01]0 processor gets an F-line exception?
Does it just bring up the GURU Alert or does it check for the presence
of a coprocessor (68881.resource??) and then pass control to it if it
exists?

Is there an OS friendly way of inserting exception vectors, rather than
for example:

    LEA      MyException, A0
    MOVE.L   A0, FLine_exception_vector

Which would really annoy the Enforcer?


Thanks,
Phil.

-- 
o|      ///   Phil Kernick             EMail:  phil@adam.adelaide.edu.au    |o
 |     ///    Departmental Engineer    Phone:  +61 8 228 5914               |
o| \\\///     Dept. of Psychology      Fax:    +61 8 224 0464               |o
 |  \///      University of Adelaide   Mail:   GPO Box 498 Adelaide SA 5001 |

GHGAQA4@cc1.kuleuven.ac.be (Tyberghein Jorrit) (06/07/91)

>What doesKS13 do when the 680[01]0 processor gets an F-line exception?
>Does it just bring up the GURU Alert or does it check for the presence
>of a coprocessor (68881.resource??) and then pass control to it if it
>exists?

If you have a 6888(1 or 2) you will not get an F-line exception
(provided you have a 68020 or 30). I don't know what will happen when
you use the 68000 or 10 with a coprocessor. My guess is that you will
get a GURU alert saying F-line exception. I don't think KS1.3 handles
this (but I may be wrong ofcourse).

>Is there an OS friendly way of inserting exception vectors, rather
>than for example:
>
>    LEA      MyException, A0
>    MOVE.L   A0, FLine_exception_vector
>
>Which would really annoy the Enforcer?

You have several options for this.
  1. Use the above code but execute it in supervisor (With the
     execbase SuperVisor function). That way, enforcer will not
     complain (I think). If Enforcer still complains you can use
     special supervisor instructions to move values in memory without
     using the MMU table, but I don't know these instructions from
     memory (I think MOVES is the one).
     Ofcourse this is not very OS-friendly.
  2. You can handle all the exceptions if you set the TC_TRAPCODE
     (or something like that) field in your task structure to your
     own routine. This routine will be executing in supervisor mode.
     The top of the (supervisor) stackframe will contain a longword
     with the exception number. The rest of the stackframe is the
     680x0 exception stack frame. To end this routine you must
     remove the longword (put there by Exec) and execute RTE (return
     from exception). This way you are OS-friendly but you can only
     trap exceptions for one task (or rather, for each task you
     patch this way).
  3. There is still another way. You can use the TRAPCODE field in
     the exec base structure. The only problem with this approach, is
     that the task-held or software error requester will appear before
     your exception routine is called. I don't know how to solve this
     (except by patching AutoRequest, EasyRequest, ...). Maybe someone
     else has an idea ?

>Thanks,
>Phil.

                           Jorrit Tyberghein

billc@cryo.rain.com (William J. Coldwell) (06/08/91)

In article <phil.676256558@adam.adelaide.edu.au> phil@adam.adelaide.edu.au (Phil Kernick) writes:
>What does KS1.3 do when the 680[01]0 processor gets an F-line exception?
>Does it just bring up the GURU Alert or does it check for the presence
>of a coprocessor (68881.resource??) and then pass control to it if it
                   ^^^^^  is supposed to be "MathIEEE.resource".
>exists?

If it gets an F-line, it Alert()'s unless you have an F-Line exception
(which is what you are hinting at down below).  This is due to the 68881
being a peripheral processor, and not a "co-processor" on 68000's, 010's,
and 008's.

>Is there an OS friendly way of inserting exception vectors, rather than
>for example:
>
>    LEA      MyException, A0
>    MOVE.L   A0, FLine_exception_vector
>
>Which would really annoy the Enforcer?

I believe that this is a case where you will have to annoy Enforcer since
you are mucking with 0 page.  How about install your exception handler, then
run Enforcer? ;-) 

>Thanks,
>o|      ///   Phil Kernick             EMail:  phil@adam.adelaide.edu.au    |o
--
  William J. Coldwell       Amiga Attitude Adjuster      Cryogenic Software
  3-D Pro | Anim. Station | CA-650 CD-ROM | CMI PA/MPB | Interact AppleTalk
  Nexus HD/Aries | CSA 40/4 Magnum | RAMbrandt | Video Blender | DoubleTalk
  Internet: billc@cryo.rain.com            UUCP: tektronix!percy!cryo!billc

carolyn@cbmvax.commodore.com (Carolyn Scheppner - CATS) (06/08/91)

In article <phil.676256558@adam.adelaide.edu.au> phil@adam.adelaide.edu.au (Phil Kernick) writes:
>What does KS1.3 do when the 680[01]0 processor gets an F-line exception?
>Does it just bring up the GURU Alert or does it check for the presence
>of a coprocessor (68881.resource??) and then pass control to it if it
>exists?

Not positive on this but perhaps my trap example in the 1.3 RKM
exec/tasks chapter will help.  It installs trap code for a task
and then proceeds to divide by zero harmlessly with the div 0
exceptions just counted by the trap code.  Make sure you
use -b0 when you compile the C part though (that was fixed in the
comments for the Fish Disk version).

As for math coprocessors, I think each of your tasks have to open
one of the mathiee... libraries to get the proper task-switch
handling of the FPU.

I believe 1.3 SetPatch installs default exception handling code for
FPU instructions executed on a machine without an FPU and that
default code probably puts up a GURU.

-- 
==========================================================================
 Carolyn Scheppner -- Tech. Mgr. CATS - Commodore Amiga Technical Support
 PHONE 215-431-9180 {uunet,rutgers}!cbmvax!carolyn  carolyn@commodore.com

   "Under the multitasking operating system, the trackdisk.device is
	the defied interface..."     - Bryce
==========================================================================

mykes@amiga0.SF-Bay.ORG (Mike Schwartz) (06/09/91)

In article <billc.3544@cryo.rain.com> billc@cryo.rain.com (William J. Coldwell) writes:
>In article <phil.676256558@adam.adelaide.edu.au> phil@adam.adelaide.edu.au (Phil Kernick) writes:
>>What does KS1.3 do when the 680[01]0 processor gets an F-line exception?
>>Does it just bring up the GURU Alert or does it check for the presence
>>of a coprocessor (68881.resource??) and then pass control to it if it
>                   ^^^^^  is supposed to be "MathIEEE.resource".
>>exists?
>
>If it gets an F-line, it Alert()'s unless you have an F-Line exception
>(which is what you are hinting at down below).  This is due to the 68881
>being a peripheral processor, and not a "co-processor" on 68000's, 010's,
>and 008's.
>
>>Is there an OS friendly way of inserting exception vectors, rather than
>>for example:
>>
>>    LEA      MyException, A0
>>    MOVE.L   A0, FLine_exception_vector
>>
>>Which would really annoy the Enforcer?
>
>I believe that this is a case where you will have to annoy Enforcer since
>you are mucking with 0 page.  How about install your exception handler, then
>run Enforcer? ;-) 
>
>>Thanks,
>>o|      ///   Phil Kernick             EMail:  phil@adam.adelaide.edu.au    |o
>--
>  William J. Coldwell       Amiga Attitude Adjuster      Cryogenic Software
>  3-D Pro | Anim. Station | CA-650 CD-ROM | CMI PA/MPB | Interact AppleTalk
>  Nexus HD/Aries | CSA 40/4 Magnum | RAMbrandt | Video Blender | DoubleTalk
>  Internet: billc@cryo.rain.com            UUCP: tektronix!percy!cryo!billc

A tip: Don't expect the vectors to really be in zeropage... Check the VBR register
to see where the vectors really are!

--
****************************************************
* I want games that look like Shadow of the Beast  *
* but play like Leisure Suit Larry.                *
****************************************************