home *** CD-ROM | disk | FTP | other *** search
/ Millennium Time Capsule / AC2000.BIN / disks / hbasic_1 / library / library.h < prev   
Encoding:
Text File  |  1997-08-29  |  4.3 KB  |  268 lines

  1.     IFD    __G2
  2.     opt    p+,c16+
  3.     ENDC
  4.  
  5. *
  6. *    LIBRARY.H include file for HiSoft BASIC © HiSoft 1987
  7. *
  8. * 30 Mar 88    changed for GENST2 compatibility
  9. *  5 May 93    inl_ macros added for inline trap calls
  10. *
  11. * Rules for HiSoft BASIC libraries
  12. * --------------------------------
  13. *
  14. * Libraries be of the form:
  15. *
  16. *    library    NAME
  17. *
  18. *    xref.l    gl_scratch    * all xrefs
  19. *    xref    get_string    
  20. *
  21. *    xdef    test1        * then the user routine names
  22. *    xdef    test2
  23. *
  24. * Note! -> xrefs and xdefs must be together before anything else
  25. *
  26. *    subdef    int,int        * test1  subroutine that's passed 2 ints
  27. *    fn_int    int,int        * test2  function that returns an int
  28. *
  29. * Note! -> The order of appearance *MUST* be the same as the xdefs
  30. *
  31. *    libstart        * after declarations before the code
  32. *
  33. *    then your code...
  34. *
  35. * until there is no more or another library statement
  36. *
  37.  
  38.     
  39. *
  40. * get_string
  41. *
  42. * takes:    a0    <- string descriptor
  43. *
  44. * returns:    a1    <- address of string
  45. *        d4.l    <- length of string
  46. *
  47. * uses:        a0,a1,d4
  48. *
  49.  
  50. *
  51. * get_array
  52. *
  53. * takes:    a0    <- array descriptor
  54. *        d0    <- number of dimensions the array should have
  55. *
  56. * returns:    a2    <- address of first element in array
  57. *        d4.l    <- total length in bytes taken by array elements
  58. *
  59. * uses:        a1,a2,d0,d4
  60. *
  61.  
  62. *
  63. * make_string
  64. *
  65. * takes:    a0    <- string descriptor
  66. *        a1    <- address of user copy of the string
  67. *        d4.l    <- length of string to be
  68. *
  69. * uses:        d0-d4,a0-a2
  70. *
  71.  
  72. *
  73. * gl_scratch
  74. *
  75. * is a 128 byte buffer which may be used as workspace. It is used by BASIC
  76. * as the DTA, so be careful after Fsfirsts etc. This is the only space on
  77. * the heap that a library may use; if you need more, use the stack.
  78. *
  79.  
  80. * New subs/functions WITHOUT parameters by Paul Jones
  81.  
  82. global    equr    a5
  83. local    equr    a4
  84. tos    equr    d7
  85. tos2    equr    d6
  86.  
  87. library    macro
  88.     module    !\1
  89.     section    CODE
  90.     endm
  91.  
  92.  
  93. subdef    macro
  94.     dc.b    48,NARG+1
  95.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  96.     endm
  97.  
  98. subdef_np    macro
  99.         dc.b    48,NARG+1
  100.         endm
  101.  
  102. fn_int    macro
  103.     dc.b    95,'%',NARG+1
  104.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  105.     endm
  106.  
  107. fn_int_np    macro
  108.         dc.b    95,'%',NARG+1
  109.         endm
  110.  
  111. fn_lng    macro
  112.     dc.b    95,'&',NARG+1
  113.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  114.     endm
  115.  
  116. fn_lng_np    macro
  117.         dc.b    95,'&',NARG+1
  118.         endm
  119.  
  120. fn_sng    macro
  121.     dc.b    95,'!',NARG+1
  122.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  123.     endm
  124.  
  125. fn_sng_np    macro
  126.         dc.b    95,'!',NARG+1
  127.         endm
  128.  
  129. fn_dbl    macro
  130.     dc.b    95,'#',NARG+1
  131.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  132.     endm
  133.  
  134. fn_dbl_np    macro
  135.         dc.b    95,'#',NARG+1
  136.         endm
  137.  
  138. fn_str_np    macro
  139.         dc.b    95,'$',NARG+1
  140.         endm
  141. params    macro
  142.     ifnc    '\1',''
  143.     dc.b    l_\1
  144.     endc
  145.     ifnc    '\2',''
  146.     dc.b    l_\2
  147.     endc
  148.     ifnc    '\3',''
  149.     dc.b    l_\3
  150.     endc
  151.     ifnc    '\4',''
  152.     dc.b    l_\4
  153.     endc
  154.     ifnc    '\5',''
  155.     dc.b    l_\5
  156.     endc
  157.     ifnc    '\6',''
  158.     dc.b    l_\6
  159.     endc
  160.     ifnc    '\7',''
  161.     dc.b    l_\7
  162.     endc
  163.     ifnc    '\8',''
  164.     dc.b    l_\8
  165.     endc
  166.     ifnc    '\9',''
  167.     dc.b    l_\9
  168.     endc
  169.     endm
  170.  
  171. array_mask    equ    8
  172. var_para_mask    equ    16
  173.  
  174. l_int    equ    1
  175. l_lng    equ    2
  176. l_sng    equ    3
  177. l_dbl    equ    4
  178. l_str    equ    5
  179.  
  180. l_aint    equ    l_int+array_mask
  181. l_alng    equ    l_lng+array_mask
  182. l_asng    equ    l_sng+array_mask
  183. l_adbl    equ    l_dbl+array_mask
  184. l_astr    equ    l_str+array_mask
  185.  
  186. l_vint    equ    l_int+var_para_mask
  187. l_vlng    equ    l_lng+var_para_mask
  188. l_vsng    equ    l_sng+var_para_mask
  189. l_vdbl    equ    l_dbl+var_para_mask
  190. l_vstr    equ    l_str+var_para_mask
  191.  
  192. libstart    macro
  193.     dc.b    0
  194.     even
  195.     endm
  196.  
  197. option    macro    string
  198.     ifc    \1,''
  199.     fail    Bad param to Option
  200.     mexit
  201.     endc
  202.     dc.b    *-z\@+1
  203.     dc.b    \1
  204. z\@
  205.     endm
  206.  
  207.  
  208. inl_sub    macro    name,trapno,callno,paras
  209.     dc.b    *-z\@+1
  210.     dc.b    ' ',48
  211.     dc.b    '\1'
  212.     dc.b    ' '
  213.     dc.b    \2,\3>>8,\3&$FF
  214.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  215. z\@
  216.     endm
  217.  
  218. inl_int    macro    name,trapno,callno,paras
  219.     dc.b    *-z\@+1
  220.     dc.b    ' ',95
  221.     dc.b    '\1','%'
  222.     dc.b    ' '
  223.     dc.b    \2,\3>>8,\3&$FF
  224.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  225. z\@
  226.     endm
  227.  
  228. inl_lng    macro    name,trapno,callno,paras
  229.     dc.b    *-z\@+1
  230.     dc.b    ' ',95
  231.     dc.b    '\1','&'
  232.     dc.b    ' '
  233.     dc.b    \2,\3>>8,\3&$FF
  234.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  235. z\@
  236.     endm
  237.  
  238. inl_sng    macro    name,trapno,callno,paras
  239.     dc.b    *-z\@+1
  240.     dc.b    ' ',95
  241.     dc.b    '\1','!'
  242.     dc.b    ' '
  243.     dc.b    \2,\3>>8,\3&$FF
  244.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  245. z\@
  246.     endm
  247.  
  248. inl_dbl    macro    name,trapno,callno,paras
  249.     dc.b    *-z\@+1
  250.     dc.b    ' ',95
  251.     dc.b    '\1','&'
  252.     dc.b    ' '
  253.     dc.b    \2,\3>>8,\3&$FF
  254.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  255. z\@
  256.     endm
  257.  
  258. inl_str    macro    name,trapno,callno,paras
  259.     dc.b    *-z\@+1
  260.     dc.b    ' ',95
  261.     dc.b    '\1','$'
  262.     dc.b    ' '
  263.     dc.b    \2,\3>>8,\3&$FF
  264.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  265. z\@
  266.     endm
  267.  
  268.