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

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