home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 377b.lha / libraries / samplelibrary / lib / samplelib_stubs.asm < prev   
Encoding:
Assembly Source File  |  1980-02-03  |  3.3 KB  |  90 lines

  1. *************************************************************************
  2. * samplelib_stubs.asm
  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. * Stubs that match this .fd file:
  26. *
  27. *    ##base _SampleBase
  28. *    ##bias 30
  29. *    ##public
  30. *    Double(n1)(D0)
  31. *    AddThese(n1,n2)(D0/D1)
  32. *    ##end
  33. *
  34. * After assembling,
  35. *   JOIN samplelib_stubs.o samplelib_lvos.o AS sample.lib
  36. *
  37. * LINK with LIBRARY sample.lib when calling sample.library functions
  38. *
  39. * NOTE: If you put all of your stubs in one file, as shown here,
  40. *       then all of the stubs will be pulled into an application
  41. *       that references one stub.  For larger libraries, you should
  42. *       place each stub in a separate assembler file, assemble them
  43. *       each separately, then join all of the .o's together.
  44. *       That will allow each stub to be independently pulled into
  45. *       the application.
  46. *       
  47. *************************************************************************
  48.    INCLUDE  "exec/types.i"
  49.    INCLUDE  "exec/libraries.i"
  50.  
  51.           section code
  52.  
  53. *------ Caller declares and initializes SampleBase in their C code
  54.  
  55.             XREF        _SampleBase
  56.  
  57. *------ Must externally reference the _LVO labels defined in samplelib_lvos
  58.  
  59.             XREF        _LVODouble
  60.             XREF        _LVOAddThese
  61.  
  62. *------ Make C function stubs available to caller
  63.  
  64.             XDEF        _Double
  65.             XDEF        _AddThese
  66.  
  67. *------- These stubs move C args from stack to appropriate registers,
  68. *------- call the library function, and return result in d0
  69.  
  70. _Double:
  71.             MOVE.L      A6,-(SP)           ;Save register(s)
  72.             MOVE.L      8(SP),D0           ;Copy param to register
  73.             MOVE.L      _SampleBase,A6     ;Library base to A6
  74.             JSR         _LVODouble(A6)     ;Go to real routine
  75.             MOVE.L      (SP)+,A6           ;Restore register(s)
  76.             RTS
  77.  
  78. _AddThese:
  79.             MOVE.L      A6,-(SP)           ;Save register(s)
  80.             MOVEM.L     8(SP),D0/D1        ;Copy params to registers
  81.                        ;8(SP)  goes into D0
  82.                        ;12(SP) goes into D1
  83.             MOVE.L      _SampleBase,A6     ;Library base to A6
  84.             JSR         _LVOAddThese(A6)   ;Go to real routine
  85.             MOVE.L      (SP)+,A6           ;Restore register(s)
  86.             RTS
  87.  
  88.           END
  89.  
  90.