home *** CD-ROM | disk | FTP | other *** search
/ Millennium Time Capsule / AC2000.BIN / disks / hbasic_1 / library / example.s < prev    next >
Encoding:
Text File  |  1997-09-12  |  1.6 KB  |  59 lines

  1.  
  2. * the PJCO library example.
  3. * this library is called "test" and shows you how to create a simple
  4. * library.
  5.  
  6.     opt    l+,c+,p+    * Linkable files, case sensitive labels
  7.                 * position indepentant code checking
  8.                 
  9.     include    LIBRARY.H    * include our bits 'n' bobs
  10.     
  11.     library TEST        * define name of library
  12.     
  13.     XREF    get_string    * this lot is needed when getting/returning
  14.     XREF    get_array    * creating strings and getting arrays.
  15.     XREF    make_string
  16.     XREF.L    gl_scratch
  17.     
  18.     XDEF    mytest1        * the name of our first command.
  19.     XDEF    mytest2        * "    "   "   "  second    "
  20.     XDEF    mytest3        * and so on
  21.         
  22.     subdef    lng,lng,int,lng    * mytest1 is a sub, inputs two longs, 
  23.                 * int and long
  24.     fn_int    vlng,aint    * mytest2 is a function which returns
  25.                 * a int, the first input is a long, but
  26.                 * HBASIC will pass it as an address to this.
  27.                 * Also, an array of ints is needed.
  28.     fn_int_np        * mytest3 is a function which returns
  29.                 * a int, but with no parameters.
  30.                 
  31. mytest1        move.l    4(sp),a0    * lng1 at 4(sp).l
  32.         move.l    8(sp),a1    *    2 at 8(sp).l
  33.         move.w    12(sp),d0    * int  at 12(sp).w
  34.         move.l    14(sp),a2    * lng3 at 14(sp).l
  35.         
  36. *        <code in here>
  37.  
  38.         RTS
  39.         
  40. mytest2        move.l    4(sp),a1    * address of variable
  41.         move.l    #1,(a1)        * put number 1 into it
  42.         
  43.         move.l    8(sp),a0    * address of ints
  44.         move.w    #1,d0        * 1 dimension
  45.         
  46.         bsr    get_array    * checks array for us
  47.                     * a2.l now is the address of first
  48.                     * element
  49.                     * d4.l is total length in bytes
  50.  
  51.         move.l    #2,tos        * return value 2
  52.  
  53.         RTS
  54.                 
  55. mytest3        
  56.         * this could be used as an initialisation code, or a 
  57.         * global access point...
  58.         
  59.         RTS