home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISOFT.LZH / HISOFT_B.MSA / LIBS / LIBRARY.H < prev    next >
Text File  |  1993-05-05  |  4KB  |  243 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. global    equr    a5
  81. local    equr    a4
  82. tos    equr    d7
  83. tos2    equr    d6
  84.  
  85. library    macro
  86.     module    !\1
  87.     section    CODE
  88.     endm
  89.  
  90.  
  91. subdef    macro
  92.     dc.b    48,NARG+1
  93.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  94.     endm
  95.  
  96. fn_int    macro
  97.     dc.b    95,'%',NARG+1
  98.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  99.     endm
  100.  
  101. fn_lng    macro
  102.     dc.b    95,'&',NARG+1
  103.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  104.     endm
  105.  
  106. fn_sng    macro
  107.     dc.b    95,'!',NARG+1
  108.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  109.     endm
  110.  
  111. fn_dbl    macro
  112.     dc.b    95,'#',NARG+1
  113.     params    \1,\2,\3,\4,\5,\6,\7,\8,\9
  114.     endm
  115.  
  116. params    macro
  117.     ifnc    '\1',''
  118.     dc.b    l_\1
  119.     endc
  120.     ifnc    '\2',''
  121.     dc.b    l_\2
  122.     endc
  123.     ifnc    '\3',''
  124.     dc.b    l_\3
  125.     endc
  126.     ifnc    '\4',''
  127.     dc.b    l_\4
  128.     endc
  129.     ifnc    '\5',''
  130.     dc.b    l_\5
  131.     endc
  132.     ifnc    '\6',''
  133.     dc.b    l_\6
  134.     endc
  135.     ifnc    '\7',''
  136.     dc.b    l_\7
  137.     endc
  138.     ifnc    '\8',''
  139.     dc.b    l_\8
  140.     endc
  141.     ifnc    '\9',''
  142.     dc.b    l_\9
  143.     endc
  144.     endm
  145.  
  146. array_mask    equ    8
  147. var_para_mask    equ    16
  148.  
  149. l_int    equ    1
  150. l_lng    equ    2
  151. l_sng    equ    3
  152. l_dbl    equ    4
  153. l_str    equ    5
  154.  
  155. l_aint    equ    l_int+array_mask
  156. l_alng    equ    l_lng+array_mask
  157. l_asng    equ    l_sng+array_mask
  158. l_adbl    equ    l_dbl+array_mask
  159. l_astr    equ    l_str+array_mask
  160.  
  161. l_vint    equ    l_int+var_para_mask
  162. l_vlng    equ    l_lng+var_para_mask
  163. l_vsng    equ    l_sng+var_para_mask
  164. l_vdbl    equ    l_dbl+var_para_mask
  165. l_vstr    equ    l_str+var_para_mask
  166.  
  167. libstart    macro
  168.     dc.b    0
  169.     even
  170.     endm
  171.  
  172. option    macro    string
  173.     ifc    \1,''
  174.     fail    Bad param to Option
  175.     mexit
  176.     endc
  177.     dc.b    *-z\@+1
  178.     dc.b    \1
  179. z\@
  180.     endm
  181.  
  182.  
  183. inl_sub    macro    name,trapno,callno,paras
  184.     dc.b    *-z\@+1
  185.     dc.b    ' ',48
  186.     dc.b    '\1'
  187.     dc.b    ' '
  188.     dc.b    \2,\3>>8,\3&$FF
  189.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  190. z\@
  191.     endm
  192.  
  193. inl_int    macro    name,trapno,callno,paras
  194.     dc.b    *-z\@+1
  195.     dc.b    ' ',95
  196.     dc.b    '\1','%'
  197.     dc.b    ' '
  198.     dc.b    \2,\3>>8,\3&$FF
  199.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  200. z\@
  201.     endm
  202.  
  203. inl_lng    macro    name,trapno,callno,paras
  204.     dc.b    *-z\@+1
  205.     dc.b    ' ',95
  206.     dc.b    '\1','&'
  207.     dc.b    ' '
  208.     dc.b    \2,\3>>8,\3&$FF
  209.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  210. z\@
  211.     endm
  212.  
  213. inl_sng    macro    name,trapno,callno,paras
  214.     dc.b    *-z\@+1
  215.     dc.b    ' ',95
  216.     dc.b    '\1','!'
  217.     dc.b    ' '
  218.     dc.b    \2,\3>>8,\3&$FF
  219.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  220. z\@
  221.     endm
  222.  
  223. inl_dbl    macro    name,trapno,callno,paras
  224.     dc.b    *-z\@+1
  225.     dc.b    ' ',95
  226.     dc.b    '\1','&'
  227.     dc.b    ' '
  228.     dc.b    \2,\3>>8,\3&$FF
  229.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  230. z\@
  231.     endm
  232.  
  233. inl_str    macro    name,trapno,callno,paras
  234.     dc.b    *-z\@+1
  235.     dc.b    ' ',95
  236.     dc.b    '\1','$'
  237.     dc.b    ' '
  238.     dc.b    \2,\3>>8,\3&$FF
  239.     params    \4,\5,\6,\7,\8,\9,\A,\B,\C
  240. z\@
  241.     endm
  242.  
  243.