home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377a.lha / libraries / exec / interrupts / rbf / rbfhandler_a.asm next >
Encoding:
Assembly Source File  |  1980-02-04  |  3.5 KB  |  89 lines

  1. *
  2. * rbfhandler_a.asm - Example interrupt handler - link with rbfhandler_c.o
  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.  
  25.     INCLUDE "exec/types.i"
  26.     INCLUDE "hardware/custom.i"
  27.     INCLUDE "hardware/intbits.i"
  28.  
  29.         XDEF    _RBFHandler
  30.  
  31. JSRLIB MACRO
  32.        XREF _LVO\1
  33.        JSR  _LVO\1(A6)
  34.        ENDM
  35.  
  36. BUFLEN    EQU    256
  37.  
  38.        STRUCTURE OURDATA,0
  39.         APTR   od_maintask
  40.         ULONG  od_mainsig
  41.         UWORD  od_bufi
  42.         STRUCT od_chbuf,BUFLEN+2
  43.         STRUCT od_flbuf,BUFLEN+2
  44.         STRUCT od_ourname,32
  45.         LABEL OURDATA_SIZEOF
  46.  
  47.  
  48. * Entered with:
  49. *  D0 == scratch
  50. *  D1 == INTENAT & INTREQR (scratch)
  51. *  A0 == custom chips (scratch)
  52. *  A1 == is_Data which is OURDATA structure (scratch)
  53. *  A5 == vector to our code (scratch)
  54. *  A6 == pointer to ExecBase (scratch)
  55. *
  56. * Note - This simple handler just receives one buffer full of serial
  57. * input data, signals main, then ignores all subsequent serial data.
  58. *
  59.     section code
  60.  
  61. _RBFHandler:                            ;entry to our interrupt handler
  62.  
  63.         MOVE.W  serdatr(A0),D1          ;get the input word (flags and char)
  64.  
  65.         MOVE.W  od_bufi(A1),D0          ;get our buffer index
  66.         CMPI.W    #BUFLEN,D0              ;no more room in our buffer ? 
  67.         BEQ.S   ExitHandler             ;yes - just exit (ignore new char)
  68.         LEA.L   od_chbuf(A1),A5         ;else get our character buffer address
  69.         MOVE.B  D1,0(A5,D0.W)           ;store character in our chbuf
  70.         LEA.L   od_flbuf(A1),A5         ;get our flag buffer address
  71.         LSR.W   #8,d1                   ;shift flags down
  72.         MOVE.B  D1,0(A5,D0.W)           ;store flags in our flbuf
  73.  
  74.         ADDQ.W  #1,D0                   ;increment our buffer index
  75.         MOVE.W  D0,od_bufi(A1)          ;   and replace it
  76.         CMPI.W  #BUFLEN,D0              ;did our buffer just become full ?
  77.         BNE.S   ExitHandler             ;no - we can exit
  78.         MOVE.L  A0,-(SP)                ;yes - save custom
  79.         MOVE.L  od_mainsig(A1),D0       ;get signal allocated by main
  80.         MOVE.L  od_maintask(A1),A1      ;and pointer to main task
  81.         JSRLIB  Signal                  ;tell main we are full
  82.         MOVE.L  (SP)+,A0                ;restore custom
  83.                                         ;Note: system call trashed D0-D1/A0-A1
  84. ExitHandler:
  85.         MOVE.W  #INTF_RBF,intreq(A0)    ;clear the interrupt
  86.         RTS                             ;return to exec
  87.  
  88.         END
  89.