home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d179 / excption.lha / Excption / excphand.a < prev    next >
Text File  |  1989-02-25  |  5KB  |  101 lines

  1. ;**************************************************************************/
  2. ;*                                                                        */
  3. ;*                    EXCEPTION HANDLER                                   */
  4. ;*               ==========================================               */
  5. ;*                                                                        */
  6. ;*                                                                        */
  7. ;*  MODULE      :  Exception                                              */
  8. ;*  NOM         :  ExcpHandler.a                                          */
  9. ;*  FONCTION    :                                                         */
  10. ;*                                                                        */
  11. ;*  RESPONSABLE :  HEWES Gerald                                           */
  12. ;*  TEL         :  (1) 46 24 20 27                                        */
  13. ;*                                                                        */
  14. ;**************************************************************************/
  15.  
  16. ;**************************************************************************/
  17. ;*                                                                        */
  18. ;* HEW 880310 Ver 0.1 : First Soft Version                                */
  19. ;* HEW 880324 Ver 0.2 : Handle 68000 exceptions                           */
  20. ;* HEW 880413 Ver 0.3 : Handle 680x0 formats                              */
  21. ;* HEW 880508 Ver 0.4 : First Released version : routines split           */
  22. ;*                      Major name changes for better homogeneity         */
  23. ;*                                                                        */
  24. ;**************************************************************************/
  25.  
  26.         xdef   _EIExcpHandler
  27.         xref   _EIEndHandler
  28.  
  29.         csect  data
  30.  
  31. ;                /************************************************/
  32. ;                /* Stack size saved after an Exception  for     */
  33. ;                /* various processors. The first number refers  */
  34. ;                /* to normal exception, the second to bus and   */
  35. ;                /* adresse exception (bigger). Warning the OS   */
  36. ;                /* adds 4 bytes (long word) to the stack with   */
  37. ;                /* exception number before giving control this  */
  38. ;                /* is not counted here. Values are in bytes     */
  39. ;                /* For 680X0 processors X <> 0 values depend    */
  40. ;                /* on the value of SP+8 which gives the format  */
  41. ;                /* value.                                       */
  42. ;                /************************************************/
  43.  
  44.  
  45. ED_ELData       dc.l  8,8,12,0,0,0,0,0,58,20,32,92,0,0,0,0   * format
  46. ED_ELNor        dc.l  6          * normal 68000 exception
  47. ED_ELBus        dc.l  14         * 68000 bus or adresse error
  48.  
  49.         csect  text
  50.  
  51. _EIExcpHandler EQU  *
  52.  
  53. start:
  54.         move.l      $0(a7),d0               * trap number
  55.         bne.s       reset
  56.         addq.l      #1,d0                   * Avoid 0
  57. ;   In the next instructions, we will dynmically determine if
  58. ;   the processor is a 68000,68010, or 68020. Stack compensation
  59. ;   is then different : on a 68000 only two exceptions normal and bus
  60. ;   on a 680X0 with X <> 0, we instead compensate by reading the format
  61. ;   at SP+a (because of the 4 bytes due to EXEC with the exception
  62. ;   number)
  63. ;     Test of processor is inspired from the compiled code of
  64. ;   whatcpu by Dave Haynie.
  65.  
  66. reset:
  67.         movea.l     #04,a0                  * get ExecBase
  68.         movea.l     (a0),a1                 * a1 = ExecBase
  69.         btst        #01,$0129(a1)           * AttnFlags = 68020 ?
  70.         bne         cpuX0                   * cpu = 68020
  71.         btst        #00,$0129(a1)           * AttnFlags = 68010 ?
  72.         beq         cpu00                   * cpu = 68000
  73. cpuX0:
  74.         lea         ED_ELData,a1            * get base of table
  75.         clr.l       d1                      * d1 = 0
  76.         move.w      $a(a7),d1               * get format bit 12-15
  77.         andi.w      #$f000,d1               * isolate format
  78.         lsr.w       #$4,d1                  * shift has to be < 7
  79.         lsr.w       #$6,d1                  * total=10, avoids * 4
  80.         adda.l      $0(a1,d1.w),a7          * ajust stack
  81.         bra         normal                  * end of 680x0
  82. cpu00:
  83.         cmp.l       #$2,d0                  * bus error ?
  84.         beq.s       bus                     * yes
  85.         cmp.l       #$3,d0                  * address error ?
  86.         beq.s       bus                     * yes
  87.         adda.l      ED_ELNor,a7             * correct SSP stack
  88.         bra         normal
  89. bus:
  90.         adda.l      ED_ELBus,a7             * correct SSP stack
  91. normal:
  92.         adda.l      #$4,a7                  * correct Exec LongWord
  93.         andi        #$dfff,sr               * move back to user mode
  94.         move.l      d0,-(a7)                * push argument
  95.         jsr         _EIEndHandler           * C handler
  96.         rts                                 * should never be here
  97.  
  98.         END
  99.  
  100. ;*************************  CIVILISATION ENDS HERE  ***********************/
  101.