home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377b.lha / libraries / samplelibrary / test / alibtest.asm next >
Encoding:
Assembly Source File  |  1980-02-03  |  3.6 KB  |  114 lines

  1. ************************************************************************
  2. *                                                                       
  3. *  alibtest.asm -- Asm example that calls the Sample.library functions  
  4. *
  5. * Copyright (c) 1990 Commodore-Amiga, Inc.
  6. *
  7. * This example is provided in electronic form by Commodore-Amiga, Inc. for
  8. * use with the 1.3 revisions of the Addison-Wesley Amiga reference manuals. 
  9. * The 1.3 Addison-Wesley Amiga Reference Manual series contains additional
  10. * information on the correct usage of the techniques and operating system
  11. * functions presented in this example.  The source and executable code of
  12. * this example may only be distributed in free electronic form, via bulletin
  13. * board or as part of a fully non-commercial and freely redistributable
  14. * diskette.  Both the source and executable code (including comments) must
  15. * be included, without modification, in any copy.  This example may not be
  16. * published in printed form or distributed with any commercial product.
  17. * However, the programming techniques and support routines set forth in
  18. * this example may be used in the development of original executable
  19. * software products for Commodore Amiga computers.
  20. * All other rights reserved.
  21. * This example is provided "as-is" and is subject to change; no warranties
  22. * are made.  All use is at your own risk.  No liability or responsibility
  23. * is assumed.
  24. *
  25. *  Linkage Info:                                                        
  26. *  FROM     Astartup.obj, alibtest.o                                    
  27. *  LIBRARY  LIB:amiga.lib, LIB:sample.lib                               
  28. *  TO       ALibTest                                                    
  29. *                                                                       
  30. ************************************************************************
  31.  
  32.  
  33.    INCLUDE   "exec/types.i"
  34.    INCLUDE   "exec/libraries.i"
  35.  
  36.    INCLUDE   "asmsupp.i"
  37.    INCLUDE   "samplebase.i"
  38.  
  39. ABSEXECBASE  EQU  4
  40.  
  41.    XDEF   _main
  42.  
  43.    XREF   _printf
  44.    XREF   _LVODouble
  45.    XREF   _LVOAddThese
  46.  
  47.    XLIB   OpenLibrary
  48.    XLIB   CloseLibrary
  49.  
  50.     section code
  51. _main:
  52.    ;------ open the test library: this will bring it in from disk
  53.    move.l   ABSEXECBASE,a6
  54.    lea      sampleName(pc),a1
  55.    moveq    #0,d0
  56.    jsr      _LVOOpenLibrary(a6)
  57.  
  58.    tst.l    d0
  59.    bne.s    1$
  60.  
  61.    ;------ couldn't find the library
  62.    pea      sampleName(pc)
  63.    pea      nolibmsg(pc)
  64.    jsr      _printf
  65.    addq.l   #8,sp
  66.  
  67.    bra      main_end
  68.  
  69. 1$:
  70.    move.l   d0,a6    ;sample.library base to a6
  71.  
  72.    ;------ print the library name, version, and revision
  73.    clr.l    d0
  74.    move.w   LIB_REVISION(a6),d0
  75.    move.l   d0,-(sp)
  76.    move.w   LIB_VERSION(a6),d0
  77.    move.l   d0,-(sp)
  78.    move.l   LN_NAME(a6),-(sp)
  79.    pea      verRevMsg(pc)
  80.    jsr      _printf           ;call Amiga.lib printf
  81.    adda.l   #16,sp            ;fix 4 long stack pushes
  82.  
  83.    ;------ call the first test function
  84.    moveq    #-7,d0
  85.    jsr      _LVODouble(a6)
  86.    move.l   d0,-(sp)
  87.    pea      doubleMsg(pc)
  88.    jsr      _printf
  89.    lea      8(sp),sp          ;fix 2 long stack pushes
  90.  
  91.    ;------ call the second test function
  92.    moveq    #21,d0
  93.    moveq    #4,d1
  94.    jsr      _LVOAddThese(a6)
  95.    move.l   d0,-(sp)
  96.    pea      addTheseMsg(pc)
  97.    jsr      _printf
  98.    lea      8(sp),sp
  99.  
  100.    ;------ close the library
  101.    move.l   a6,a1
  102.    move.l   ABSEXECBASE,a6
  103.    jsr      _LVOCloseLibrary(a6)
  104.  
  105. main_end:
  106.             rts
  107.  
  108. sampleName:  SAMPLENAME
  109. nolibmsg:    dc.b   'can not open library "%s"',10,0
  110. doubleMsg:   dc.b   'Function Double(-7) returned %ld',10,0
  111. addTheseMsg: dc.b   'Function AddThese(21,4) returned %ld',10,0
  112. verRevMsg:   dc.b   '%s   Version %ld   Revision %ld',10,0
  113.    END
  114.