You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
3.1 KiB

26 years ago
26 years ago
  1. ; Copyright (C) 2000 MySQL AB
  2. ;
  3. ; This library is free software; you can redistribute it and/or
  4. ; modify it under the terms of the GNU Library General Public
  5. ; License as published by the Free Software Foundation; version 2
  6. ; of the License.
  7. ;
  8. ; This library is distributed in the hope that it will be useful,
  9. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. ; Library General Public License for more details.
  12. ;
  13. ; You should have received a copy of the GNU Library General Public
  14. ; License along with this library; if not, write to the Free
  15. ; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  16. ; MA 02111-1307, USA
  17. ; Some useful macros
  18. .386P
  19. .387
  20. _FLAT equ 0 ;FLAT memory model
  21. _STDCALL equ 0 ;default to _stdcall
  22. I386 equ 1
  23. begcode macro module
  24. if _FLAT
  25. _TEXT segment dword use32 public 'CODE'
  26. assume CS:FLAT,DS:FLAT,SS:FLAT
  27. else
  28. _TEXT segment dword public 'CODE'
  29. assume CS:_TEXT
  30. endif
  31. endm
  32. endcode macro module
  33. _TEXT ENDS
  34. endm
  35. begdata macro
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ; Set up segments for data
  38. ; Regular initialized data goes in _DATA
  39. _DATA segment dword public 'DATA'
  40. _DATA ends
  41. ;Function pointers to constructors
  42. XIB segment dword public 'DATA'
  43. XIB ends
  44. XI segment dword public 'DATA'
  45. XI ends
  46. XIE segment dword public 'DATA'
  47. XIE ends
  48. ;Function pointers to destructors
  49. XCB segment dword public 'DATA'
  50. XCB ends
  51. XC segment dword public 'DATA'
  52. XC ends
  53. XCE segment dword public 'DATA'
  54. XCE ends
  55. ;Constant data, such as switch tables, go here.
  56. CONST segment dword public 'CONST'
  57. CONST ends
  58. ;Segment for uninitialized data. This is set to 0 by the startup code/OS,
  59. ;so it does not consume room in the executable file.
  60. _BSS segment dword public 'BSS'
  61. _BSS ends
  62. HUGE_BSS segment dword public 'HUGE_BSS'
  63. HUGE_BSS ends
  64. EEND segment dword public 'ENDBSS'
  65. EEND ends
  66. STACK segment para stack 'STACK'
  67. STACK ends
  68. DGROUP group _DATA,XIB,XI,XIE,XCB,XC,XCE,CONST,_BSS,EEND,STACK
  69. _DATA segment
  70. if _FLAT
  71. assume DS:FLAT
  72. else
  73. assume DS:DGROUP
  74. endif
  75. endm
  76. enddata macro
  77. _DATA ends
  78. endm
  79. P equ 8 ; Offset of start of parameters on the stack frame
  80. ; From EBP assuming EBP was pushed.
  81. PS equ 4 ; Offset of start of parameters on the stack frame
  82. ; From ESP assuming EBP was NOT pushed.
  83. ESeqDS equ 0
  84. FSeqDS equ 0
  85. GSeqDS equ 0
  86. SSeqDS equ 1
  87. SIZEPTR equ 4 ; Size of a pointer
  88. LPTR equ 0
  89. SPTR equ 1
  90. LCODE equ 0
  91. func macro name
  92. _&name proc near
  93. ifndef name
  94. name equ _&name
  95. endif
  96. endm
  97. callm macro name
  98. call _&name
  99. endm
  100. ;Macros to replace public, extrn, and endp for C-callable assembly routines,
  101. ; and to define labels: c_label defines labels,
  102. ; c_public replaces public, c_extrn replaces extrn, and c_endp replaces endp
  103. c_name macro name
  104. name equ _&name
  105. endm
  106. c_label macro name
  107. _&name:
  108. endm
  109. c_endp macro name
  110. _&name ENDP
  111. endm
  112. clr macro list ;clear a register
  113. irp reg,<list>
  114. xor reg,reg
  115. endm
  116. endm
  117. jmps macro lbl
  118. jmp short lbl
  119. endm