home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / exec / tasks / trap / trap_a.asm next >
Encoding:
Assembly Source File  |  1980-02-04  |  2.2 KB  |  54 lines

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