home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / dev / rkrm.lha / RKRM / Exec_Library / Tasks / trap_a.asm < prev    next >
Assembly Source File  |  1992-09-03  |  2KB  |  52 lines

  1. * trap_a.asm - Example trap handling code (leaves D0 intact).  Entered
  2. * in supervisor mode with the following on the supervisor stack:
  3. *    0(sp).l = trap#
  4. *    4(sp) Processor dependent exception frame
  5. *
  6. *
  7. * Copyright (c) 1992 Commodore-Amiga, Inc.
  8. *
  9. * This example is provided in electronic form by Commodore-Amiga, Inc. for
  10. * use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
  11. * published by Addison-Wesley (ISBN 0-201-56774-1).
  12. *
  13. * The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
  14. * information on the correct usage of the techniques and operating system
  15. * functions presented in these examples.  The source and executable code
  16. * of these examples may only be distributed in free electronic form, via
  17. * bulletin board or as part of a fully non-commercial and freely
  18. * redistributable diskette.  Both the source and executable code (including
  19. * comments) must be included, without modification, in any copy.  This
  20. * example may not be published in printed form or distributed with any
  21. * commercial product.  However, the programming techniques and support
  22. * routines set forth in these examples may be used in the development
  23. * of original executable software products for Commodore Amiga computers.
  24. *
  25. * All other rights reserved.
  26. *
  27. * This example is provided "as-is" and is subject to change; no
  28. * warranties are made.  All use is at your own risk. No liability or
  29. * responsibility is assumed.
  30.  
  31.     INCLUDE "exec/types.i"
  32.     INCLUDE "libraries/dos.i"
  33.  
  34.         XDEF _trapa
  35.         XREF _countdiv0
  36.         XREF _oldTrapCode
  37.  
  38.         CODE
  39. _trapa:                                 ; our trap handler entry
  40.         CMPI.L  #5,(SP)                 ; is this a divide by zero ?
  41.         BNE.S   notdiv0                 ; no
  42.         ADD.L   #1,_countdiv0           ; yes, increment our div0 count
  43. endtrap:
  44.         ADDQ    #4,SP                   ; remove exception number from SSP
  45.         RTE                             ; return from exception
  46. notdiv0:
  47.         TST.L   _oldTrapCode            ; is there another trap handler ?
  48.         BEQ.S   endtrap                 ; no, so we'll exit
  49.         MOVE.L  _oldTrapCode,-(SP)      ; yes, go on to old TrapCode
  50.         RTS                             ; jumps to old TrapCode
  51.  
  52.         END