home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / Devcon_Extras / Example_Code / SampleLibrary / test / alibtest.asm next >
Encoding:
Assembly Source File  |  1992-08-27  |  2.7 KB  |  96 lines

  1. *************************************************************************
  2. *                                                                       *
  3. *  alibtest.asm -- Asm example that calls the Sample.library functions  *
  4. *                                                                       *
  5. *  Copyright 1988 Commodore Amiga Inc.  All rights reserved.            *
  6. *                                                                       *
  7. *  Linkage Info:                                                        *
  8. *  FROM     Astartup.obj, alibtest.o                                    *
  9. *  LIBRARY  LIB:amiga.lib, LIB:sample.lib                               *
  10. *  TO       ALibTest                                                    *
  11. *                                                                       *
  12. *************************************************************************
  13.  
  14.  
  15.    INCLUDE   "exec/types.i"
  16.    INCLUDE   "exec/libraries.i"
  17.  
  18.    INCLUDE   "asmsupp.i"
  19.    INCLUDE   "samplebase.i"
  20.  
  21. ABSEXECBASE  EQU  4
  22.  
  23.    XDEF   _main
  24.  
  25.    XREF   _printf
  26.    XREF   _LVODouble
  27.    XREF   _LVOAddThese
  28.  
  29.    XLIB   OpenLibrary
  30.    XLIB   CloseLibrary
  31.  
  32.  
  33. _main:
  34.    ;------ open the test library: this will bring it in from disk
  35.    move.l   ABSEXECBASE,a6
  36.    lea      sampleName(pc),a1
  37.    moveq    #0,d0
  38.    jsr      _LVOOpenLibrary(a6)
  39.  
  40.    tst.l    d0
  41.    bne.s    1$
  42.  
  43.    ;------ couldn't find the library
  44.    pea      sampleName(pc)
  45.    pea      nolibmsg(pc)
  46.    jsr      _printf
  47.    addq.l   #8,sp
  48.  
  49.    bra      main_end
  50.  
  51. 1$:
  52.    move.l   d0,a6    ;sample.library base to a6
  53.  
  54.    ;------ print the library name, version, and revision
  55.    clr.l    d0
  56.    move.w   LIB_REVISION(a6),d0
  57.    move.l   d0,-(sp)
  58.    move.w   LIB_VERSION(a6),d0
  59.    move.l   d0,-(sp)
  60.    move.l   LN_NAME(a6),-(sp)
  61.    pea      verRevMsg(pc)
  62.    jsr      _printf           ;call Amiga.lib printf
  63.    adda.l   #16,sp            ;fix 4 long stack pushes
  64.  
  65.    ;------ call the first test function
  66.    moveq    #-7,d0
  67.    jsr      _LVODouble(a6)
  68.    move.l   d0,-(sp)
  69.    pea      doubleMsg(pc)
  70.    jsr      _printf
  71.    lea      8(sp),sp          ;fix 2 long stack pushes
  72.  
  73.    ;------ call the second test function
  74.    moveq    #21,d0
  75.    moveq    #4,d1
  76.    jsr      _LVOAddThese(a6)
  77.    move.l   d0,-(sp)
  78.    pea      addTheseMsg(pc)
  79.    jsr      _printf
  80.    lea      8(sp),sp
  81.  
  82.    ;------ close the library
  83.    move.l   a6,a1
  84.    move.l   ABSEXECBASE,a6
  85.    jsr      _LVOCloseLibrary(a6)
  86.  
  87. main_end:
  88.             rts
  89.  
  90. sampleName:  SAMPLENAME
  91. nolibmsg:    dc.b   'can not open library "%s"',10,0
  92. doubleMsg:   dc.b   'Function Double(-7) returned %ld',10,0
  93. addTheseMsg: dc.b   'Function AddThese(21,4) returned %ld',10,0
  94. verRevMsg:   dc.b   '%s   Version %ld   Revision %ld',10,0
  95.    END
  96.