1
by brian
clean slate |
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 |
||
18 |
; Some useful macros
|
|
19 |
||
20 |
.386P
|
|
21 |
.387
|
|
22 |
||
23 |
_FLAT equ 0 ;FLAT memory model |
|
24 |
_STDCALL equ 0 ;default to _stdcall |
|
25 |
I386 equ 1 |
|
26 |
||
27 |
begcode macro module |
|
28 |
if _FLAT |
|
29 |
_TEXT segment dword use32 public 'CODE' |
|
30 |
assume CS:FLAT,DS:FLAT,SS:FLAT |
|
31 |
else
|
|
32 |
_TEXT segment dword public 'CODE' |
|
33 |
assume CS:_TEXT |
|
34 |
endif
|
|
35 |
endm
|
|
36 |
||
37 |
endcode macro module |
|
38 |
_TEXT ENDS |
|
39 |
endm
|
|
40 |
||
41 |
begdata macro |
|
42 |
||
43 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
44 |
; Set up segments for data
|
|
45 |
; Regular initialized data goes in _DATA
|
|
46 |
||
47 |
_DATA segment dword public 'DATA' |
|
48 |
_DATA ends |
|
49 |
||
50 |
;Function pointers to constructors
|
|
51 |
XIB segment dword public 'DATA' |
|
52 |
XIB ends |
|
53 |
XI segment dword public 'DATA' |
|
54 |
XI ends |
|
55 |
XIE segment dword public 'DATA' |
|
56 |
XIE ends |
|
57 |
||
58 |
;Function pointers to destructors
|
|
59 |
XCB segment dword public 'DATA' |
|
60 |
XCB ends |
|
61 |
XC segment dword public 'DATA' |
|
62 |
XC ends |
|
63 |
XCE segment dword public 'DATA' |
|
64 |
XCE ends |
|
65 |
||
66 |
;Constant data, such as switch tables, go here.
|
|
67 |
||
68 |
CONST segment dword public 'CONST' |
|
69 |
CONST ends |
|
70 |
||
71 |
;Segment for uninitialized data. This is set to 0 by the startup code/OS,
|
|
72 |
;so it does not consume room in the executable file.
|
|
73 |
||
74 |
_BSS segment dword public 'BSS' |
|
75 |
_BSS ends |
|
76 |
||
77 |
HUGE_BSS segment dword public 'HUGE_BSS' |
|
78 |
HUGE_BSS ends |
|
79 |
||
80 |
EEND segment dword public 'ENDBSS' |
|
81 |
EEND ends |
|
82 |
||
83 |
STACK segment para stack 'STACK' |
|
84 |
STACK ends |
|
85 |
DGROUP group _DATA,XIB,XI,XIE,XCB,XC,XCE,CONST,_BSS,EEND,STACK |
|
86 |
||
87 |
_DATA segment |
|
88 |
if _FLAT |
|
89 |
assume DS:FLAT |
|
90 |
else
|
|
91 |
assume DS:DGROUP |
|
92 |
endif
|
|
93 |
endm
|
|
94 |
||
95 |
enddata macro |
|
96 |
_DATA ends |
|
97 |
endm
|
|
98 |
||
99 |
P equ 8 ; Offset of start of parameters on the stack frame |
|
100 |
; From EBP assuming EBP was pushed.
|
|
101 |
PS equ 4 ; Offset of start of parameters on the stack frame |
|
102 |
; From ESP assuming EBP was NOT pushed.
|
|
103 |
ESeqDS equ 0 |
|
104 |
FSeqDS equ 0 |
|
105 |
GSeqDS equ 0 |
|
106 |
SSeqDS equ 1 |
|
107 |
SIZEPTR equ 4 ; Size of a pointer |
|
108 |
LPTR equ 0 |
|
109 |
SPTR equ 1 |
|
110 |
LCODE equ 0 |
|
111 |
||
112 |
func macro name |
|
113 |
_&name proc near |
|
114 |
ifndef name |
|
115 |
name equ _&name |
|
116 |
endif
|
|
117 |
endm
|
|
118 |
||
119 |
callm macro name |
|
120 |
call _&name |
|
121 |
endm
|
|
122 |
||
123 |
;Macros to replace public, extrn, and endp for C-callable assembly routines,
|
|
124 |
; and to define labels: c_label defines labels,
|
|
125 |
; c_public replaces public, c_extrn replaces extrn, and c_endp replaces endp
|
|
126 |
||
127 |
c_name macro name |
|
128 |
name equ _&name |
|
129 |
endm
|
|
130 |
||
131 |
c_label macro name |
|
132 |
_&name: |
|
133 |
endm
|
|
134 |
||
135 |
c_endp macro name |
|
136 |
_&name ENDP |
|
137 |
endm
|
|
138 |
||
139 |
clr macro list ;clear a register |
|
140 |
irp reg,<list> |
|
141 |
xor reg,reg |
|
142 |
endm
|
|
143 |
endm
|
|
144 |
||
145 |
jmps macro lbl |
|
146 |
jmp short lbl |
|
147 |
endm
|