home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / easy.asm < prev    next >
Encoding:
Assembly Source File  |  1992-08-21  |  1.7 KB  |  37 lines

  1. **********************************************************************
  2. * A complete ready-to-assemble example of how to open an Amiga function
  3. * library in 68000 assembler.  In this case the Intuition function library
  4. * is opened and one of its functions, DisplayBeep() is called.
  5. *
  6. * When calling an Amiga function, the library base pointer *must* be in
  7. * A6 (the library is free to depend on this).  Registers D0, D1, A0
  8. * and A1 may be destroyed by the library, all others will be preserved.
  9. *
  10. _AbsExecBase EQU  4          ;System pointer to Exec's library base
  11.  
  12.         XREF    _LVOOpenLibrary       ;Offset from Exec base for OpenLibrary()
  13.         XREF    _LVOCloseLibrary      ;Offset from Exec base for CloseLibrary()
  14.         XREF    _LVODisplayBeep       ;Offset from Intuition base for DisplayBeep()
  15.  
  16.         move.l  _AbsExecBase,a6       ;Move exec.library base to a6
  17.         lea.l   IntuiName(pc),a1      ;Pointer to "intuition.library" string
  18.         moveq   #33,d0                ;Version of library needed
  19.         jsr     _LVOOpenLibrary(a6)   ;Call Exec's OpenLibrary() and
  20.         tst.l   d0                    ;check to see if it succeeded
  21.         bne.s   open_ok
  22.         moveq   #20,d0                ;Set failure code
  23.         rts                           ;Failed exit
  24.  
  25. open_ok move.l  d0,a6                 ;Put IntuitionBase in a6.
  26.         suba.l  a0,a0                 ;Load zero into a0
  27.         jsr     _LVODisplayBeep(a6)   ;Call Intuition's DisplayBeep()
  28.  
  29.         move.l  a6,a1                 ;Put IntuitionBase into a1
  30.         move.l  _AbsExecBase,a6
  31.         jsr     _LVOCloseLibrary(a6)  ;Call Exec's CloseLibrary()
  32.         moveq   #0,d0                 ;Set return code
  33.         rts
  34.  
  35. IntuiName:      dc.b 'intuition.library',0
  36.         END
  37.