home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 3.ddi / STARTUP.ZIP / STARTUP.INC < prev    next >
Encoding:
Text File  |  1990-09-01  |  5.0 KB  |  263 lines

  1.     .xlist
  2. ;
  3. ;    Common assembly language definitions/macros for Paradigm LOCATE
  4. ;    Copyright (C) 1989, 1990 Paradigm Systems.  All rights reserved.
  5. ;
  6. ;    Many of the macros define C-style functions and data declarations
  7. ;    by appending a leading underscore to public symbols.  To fixup these
  8. ;    symbols, a new symbol is defined which replaces all occurrences of
  9. ;    the original.  This permits the C declaration to be used except when
  10. ;    a name clash occurs.
  11. ;
  12. ;    Should a name clash occur, such as in exit() and _exit() (since _exit
  13. ;    is the alias created for the symbol exit), the use of manual delcarations
  14. ;    must be used.
  15. ;
  16.  
  17. NOWARN    PDC                ; Disable pass 1 warnings
  18. IF1                    ; Pass 1 definitions
  19.     %out    Paradigm LOCATE Compiler Startup Version 1.00
  20.  
  21. ;
  22. ;    Pointer shorthand for assembly language
  23. ;
  24. bptr    equ    byte ptr        ; Data references
  25. wptr    equ    word ptr
  26. dptr    equ    dword ptr
  27. qptr    equ    qword ptr
  28.  
  29. nptr    equ    near ptr        ; Function references
  30. fptr    equ    far ptr
  31.  
  32. ;
  33. ;    Define a macro for defining segments.  The paramters in order are
  34. ;        - Segment name
  35. ;        - Alignment
  36. ;        - Combine type
  37. ;        - Class name
  38. ;        - Group name
  39. ;
  40. ;    All macro arguments are mandatory except for a group name.
  41. ;
  42. DefSeg    macro    sname, salign, scomb, sclass, sgroup
  43. .errb    <sname>
  44. .errb    <salign>
  45. .errb    <scomb>
  46. .errb    <sclass>
  47. sname    segment    salign    scomb    '&sclass'
  48. sname    ends
  49. ifnb    <sgroup>
  50. sgroup    group    sname
  51. endif
  52. endm
  53.  
  54. ;
  55. ;    Some simple macros for defining global (public) data where
  56. ;        B - byte    W - word
  57. ;        D - dword    Q - qword
  58. ;    and 'ginit' is an optional initializer.
  59. ;
  60. GlobalB    macro    gname, ginit
  61. .errb    <gname>
  62. ifnb    <ginit>
  63. _&gname    db    ginit
  64. else
  65. _&gname    db    ?
  66. endif
  67. public    _&gname
  68. gname    equ    _&gname
  69. endm    ; GlobalB
  70.  
  71. GlobalW    macro    gname, ginit
  72. .errb    <gname>
  73. ifnb    <ginit>
  74. _&gname    dw    ginit
  75. else
  76. _&gname    dw    ?
  77. endif
  78. public    _&gname
  79. gname    equ    _&gname
  80. endm    ; GlobalW
  81.  
  82. GlobalD    macro    gname, ginit
  83. .errb    <gname>
  84. ifnb    <ginit>
  85. _&gname    dd    ginit
  86. else
  87. _&gname    dd    ?
  88. endif
  89. public    _&gname
  90. gname    equ    _&gname
  91. endm    ; GlobalD
  92.  
  93. GlobalQ    macro    gname, ginit
  94. .errb    <gname>
  95. ifnb    <ginit>
  96. _&gname    dq    ginit
  97. else
  98. _&gname    dq    ?
  99. endif
  100. public    _&gname
  101. gname    equ    _&gname
  102. endm    ; GlobalQ
  103.  
  104. ;
  105. ;    Some simple macros for defining local (non-public) data where
  106. ;        B - byte    W - word
  107. ;        D - dword    Q - qword
  108. ;    and 'linit' is an optional initializer.
  109. ;
  110. LocalB    macro    lname, linit
  111. .errb    <lname>
  112. ifnb    <linit>
  113. lname    db    linit
  114. else
  115. lname    db    ?
  116. endif
  117. endm    ; LocalB
  118.  
  119. LocalW    macro    lname, linit
  120. .errb    <lname>
  121. ifnb    <linit>
  122. lname    dw    linit
  123. else
  124. lname    dw    ?
  125. endif
  126. endm    ; LocalW
  127.  
  128. LocalD    macro    lname, linit
  129. .errb    <lname>
  130. ifnb    <linit>
  131. lname    dd    linit
  132. else
  133. lname    dd    ?
  134. endif
  135. endm    ; LocalD
  136.  
  137. LocalQ    macro    lname, linit
  138. .errb    <lname>
  139. ifnb    <linit>
  140. lname    dq    linit
  141. else
  142. lname    dq    ?
  143. endif
  144. endm    ; LocalQ
  145.  
  146. ;
  147. ;    A pair of macros for defining public functions and marking the end.
  148. ;    use BegProc to define a function with an optional forced memory model
  149. ;    or use the default current memory model.  The macro EndProc is then
  150. ;    used to close the function.
  151. ;
  152. BegProc    macro    pname, pmodel
  153. .errb    <pname>
  154. ifb    <pmodel>
  155. if    @CodeSize EQ 0
  156. _&pname    proc    near
  157. else
  158. _&pname    proc    far
  159. endif
  160. else
  161. _&pname    proc    pmodel
  162. endif
  163. public    _&pname
  164. pname    equ    _&pname
  165. endm    ; BegProc
  166.  
  167. EndProc    macro    pname
  168. .errb    <pname>
  169. _&pname    endp
  170. endm    ; EndProc
  171.  
  172. ;
  173. ;    Some simple macros for defining labels where
  174. ;        B - byte    W - word
  175. ;        D - dword    Q - qword
  176. ;    The optional parameter 'lpub' can be used to make the label public.
  177. ;
  178. LabelB    macro    lname, lpub
  179. .errb    <lname>
  180. ifnb    <lpub>
  181. public    _&lname
  182. _&lname    label    byte
  183. lname    equ    _&lname
  184. else
  185. lname    label    byte
  186. endif
  187. endm    ; LabelB
  188.  
  189. LabelW    macro    lname, lpub
  190. .errb    <lname>
  191. ifnb    <lpub>
  192. _&lname    label    word
  193. public    _&lname
  194. lname    equ    _&lname
  195. else
  196. lname    label    word
  197. endif
  198. endm    ; LabelW
  199.  
  200. LabelD    macro    lname, lpub
  201. .errb    <lname>
  202. ifnb    <lpub>
  203. public    _&lname
  204. _&lname    label    dword
  205. lname    equ    _&lname
  206. else
  207. lname    label    dword
  208. endif    ; ifnb
  209. endm    ; LabelD
  210.  
  211. LabelQ    macro    lname, lpub
  212. .errb    <lname>
  213. ifnb    <lpub>
  214. public    _&lname
  215. _&lname    label    qword
  216. lname    equ    _&lname
  217. else
  218. lname    label    qword
  219. endif
  220. endm    ; LabelQ
  221.  
  222. ;
  223. ;    A macro to determine the near/far-ness of an external function
  224. ;    based on the defined memory model.
  225. ;
  226. ExtProc    macro    ename, emodel
  227. .errb    <ename>
  228. ifb    <emodel>
  229. if    @CodeSize EQ 0
  230. extrn    _&ename : near
  231. else
  232. extrn    _&ename : far
  233. endif
  234. else
  235. extrn    _&ename : emodel
  236. endif
  237. ename    equ    _&ename
  238. endm    ; ExtProc
  239.  
  240. ;
  241. ;    Some useful constants for checking code/data memory models and
  242. ;    the floating point options.
  243. ;
  244. MM_NEAR        equ    0        ; Small code/data model definition
  245. MM_FAR        equ    1        ; Large code/data model definition
  246. MM_HUGE        equ    2        ; Huge code/data model definition
  247.  
  248. FPDFT        equ    0        ; Default floating point option
  249. FPALT        equ    1        ; Alternate math
  250. FPEMU        equ    2        ; Emulator math
  251. FP87        equ    3        ; 80x87 in-line code
  252.  
  253. ;
  254. ;    TDREM exit codes intercepted by and handled by the startup code
  255. ;
  256. TDE_ABORT    equ    246        ; abort()
  257. TDE_STKOVL    equ    245        ; stack overflow
  258. TDE_FPEXCP    equ    244        ; floating point exception
  259.  
  260. ENDIF    ; IF1
  261. WARN    PDC                ; Turn warnings back on
  262.     .list
  263.