Rev 617 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
617 | mikedld | 1 | |
2 | |||
3 | |||
4 | { common |
||
5 | if ~ arg eq |
||
6 | reverse |
||
7 | pushd arg |
||
8 | common |
||
9 | end if |
||
10 | call proc } |
||
11 | |||
12 | |||
13 | { common |
||
14 | if ~ arg eq |
||
15 | reverse |
||
16 | pushd arg |
||
17 | common |
||
18 | end if |
||
19 | call [proc] } |
||
20 | |||
21 | |||
22 | { common |
||
23 | size@ccall = 0 |
||
24 | if ~ arg eq |
||
25 | reverse |
||
26 | pushd arg |
||
27 | size@ccall = size@ccall+4 |
||
28 | common |
||
29 | end if |
||
30 | call proc |
||
31 | if size@ccall |
||
32 | add esp,size@ccall |
||
33 | end if } |
||
34 | |||
35 | |||
36 | { common |
||
37 | size@ccall = 0 |
||
38 | if ~ arg eq |
||
39 | reverse |
||
40 | pushd arg |
||
41 | size@ccall = size@ccall+4 |
||
42 | common |
||
43 | end if |
||
44 | call [proc] |
||
45 | if size@ccall |
||
46 | add esp,size@ccall |
||
47 | end if } |
||
48 | |||
49 | |||
50 | { common |
||
51 | match name params, args> |
||
52 | \{ define@proc name, |
||
53 | |||
54 | |||
55 | |||
56 | |||
57 | { local loc |
||
4039 | heavyiron | 58 | loc = (localbytes+3) and (not 3) |
59 | parmbase@proc equ ebp+8 |
||
60 | localbase@proc equ ebp-loc |
||
61 | if parmbytes | localbytes |
||
62 | push ebp |
||
617 | mikedld | 63 | mov ebp,esp |
64 | if localbytes |
||
65 | sub esp,loc |
||
4039 | heavyiron | 66 | end if |
617 | mikedld | 67 | end if |
68 | irps reg, reglist \{ push reg \} } |
||
69 | |||
70 | |||
71 | |||
72 | |||
73 | { irps reg, reglist \{ reverse pop reg \} |
||
74 | if parmbytes | localbytes |
||
75 | leave |
||
76 | end if |
||
77 | if flag and 10000b |
||
78 | retn |
||
79 | else |
||
80 | retn parmbytes |
||
81 | end if } |
||
82 | |||
83 | |||
4039 | heavyiron | 84 | |
85 | |||
617 | mikedld | 86 | { local params,flag,regs,parmbytes,localbytes,current |
87 | if used name |
||
88 | name: |
||
89 | match =stdcall args, statement \{ params equ args |
||
90 | flag = 11b \} |
||
91 | match =stdcall, statement \{ params equ |
||
92 | flag = 11b \} |
||
93 | match =c args, statement \{ params equ args |
||
94 | flag = 10001b \} |
||
95 | match =c, statement \{ params equ |
||
96 | flag = 10001b \} |
||
97 | match =params, params \{ params equ statement |
||
98 | flag = 0 \} |
||
99 | match =uses reglist=,args, params \{ regs equ reglist |
||
100 | params equ args \} |
||
101 | match =regs =uses reglist, regs params \{ regs equ reglist |
||
102 | params equ \} |
||
103 | match =regs, regs \{ regs equ \} |
||
104 | match prologue:reglist, prologue@proc: |
||
4039 | heavyiron | 105 | virtual at parmbase@proc |
106 | match =,args, params \{ defargs@proc args \} |
||
617 | mikedld | 107 | match =args@proc args, args@proc params \{ defargs@proc args \} |
108 | parmbytes = $-(parmbase@proc) |
||
4039 | heavyiron | 109 | end virtual |
617 | mikedld | 110 | name # % = parmbytes/4 |
111 | all@vars equ |
||
112 | current = 0 |
||
113 | macro locals |
||
114 | \{ virtual at localbase@proc+current |
||
4039 | heavyiron | 115 | macro label def \\{ match . type,def> \\\{ deflocal@proc .,label, |
617 | mikedld | 116 | struc db [val] \\{ \common deflocal@proc .,db,val \\} |
117 | struc du [val] \\{ \common deflocal@proc .,du,val \\} |
||
118 | struc dw [val] \\{ \common deflocal@proc .,dw,val \\} |
||
119 | struc dp [val] \\{ \common deflocal@proc .,dp,val \\} |
||
120 | struc dd [val] \\{ \common deflocal@proc .,dd,val \\} |
||
121 | struc dt [val] \\{ \common deflocal@proc .,dt,val \\} |
||
122 | struc dq [val] \\{ \common deflocal@proc .,dq,val \\} |
||
123 | struc rb cnt \\{ deflocal@proc .,rb cnt, \\} |
||
124 | struc rw cnt \\{ deflocal@proc .,rw cnt, \\} |
||
125 | struc rp cnt \\{ deflocal@proc .,rp cnt, \\} |
||
126 | struc rd cnt \\{ deflocal@proc .,rd cnt, \\} |
||
127 | struc rt cnt \\{ deflocal@proc .,rt cnt, \\} |
||
128 | struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \} |
||
129 | macro endl |
||
130 | \{ purge label |
||
131 | restruc db,du,dw,dp,dd,dt,dq |
||
132 | restruc rb,rw,rp,rd,rt,rq |
||
133 | current = $-(localbase@proc) |
||
4039 | heavyiron | 134 | end virtual \} |
617 | mikedld | 135 | macro ret operand |
136 | \{ match any, operand \\{ retn operand \\} |
||
137 | match , operand \\{ match epilogue:reglist, epilogue@proc: |
||
4039 | heavyiron | 138 | macro finish@proc |
139 | \{ localbytes = current |
||
140 | match close:reglist, close@proc: |
||
141 | end if \} } |
||
142 | |||
617 | mikedld | 143 | |
144 | { common |
||
145 | if ~ arg eq |
||
146 | forward |
||
147 | local ..arg,current@arg |
||
148 | match argname:type, arg |
||
149 | \{ current@arg equ argname |
||
150 | label ..arg type |
||
151 | argname equ ..arg |
||
152 | if qqword eq type |
||
4039 | heavyiron | 153 | dd ?,?,?,?,?,?,?,? |
154 | else if dqword eq type |
||
155 | dd ?,?,?,? |
||
617 | mikedld | 156 | else if tbyte eq type |
157 | dd ?,?,? |
||
158 | else if qword eq type | pword eq type |
||
159 | dd ?,? |
||
160 | else |
||
161 | dd ? |
||
162 | end if \} |
||
163 | match =current@arg,current@arg |
||
164 | \{ current@arg equ arg |
||
165 | arg equ ..arg |
||
166 | ..arg dd ? \} |
||
167 | common |
||
168 | args@proc equ current@arg |
||
169 | forward |
||
170 | restore current@arg |
||
171 | common |
||
172 | end if } |
||
173 | |||
174 | |||
4039 | heavyiron | 175 | |
176 | |||
617 | mikedld | 177 | { common |
178 | match vars, all@vars \{ all@vars equ all@vars, \} |
||
179 | all@vars equ all@vars name |
||
180 | forward |
||
181 | local ..var,..tmp |
||
182 | ..var def val |
||
4039 | heavyiron | 183 | match =?, val \{ ..tmp equ \} |
617 | mikedld | 184 | match any =?, val \{ ..tmp equ \} |
4039 | heavyiron | 185 | match any (=?), val \{ ..tmp equ \} |
186 | match =label, def \{ ..tmp equ \} |
||
187 | match tmp : value, ..tmp : val |
||
617 | mikedld | 188 | \{ tmp: end virtual |
189 | initlocal@proc ..var,def value |
||
190 | virtual at tmp\} |
||
191 | common |
||
192 | match first rest, ..var, \{ name equ first \} } |
||
193 | |||
194 | |||
4039 | heavyiron | 195 | |
196 | |||
617 | mikedld | 197 | { virtual at name |
198 | def |
||
199 | size@initlocal = $ - name |
||
200 | end virtual |
||
201 | position@initlocal = 0 |
||
202 | while size@initlocal > position@initlocal |
||
203 | virtual at name |
||
204 | def |
||
205 | if size@initlocal - position@initlocal < 2 |
||
206 | current@initlocal = 1 |
||
207 | load byte@initlocal byte from name+position@initlocal |
||
208 | else if size@initlocal - position@initlocal < 4 |
||
209 | current@initlocal = 2 |
||
210 | load word@initlocal word from name+position@initlocal |
||
211 | else |
||
212 | current@initlocal = 4 |
||
213 | load dword@initlocal dword from name+position@initlocal |
||
214 | end if |
||
215 | end virtual |
||
216 | if current@initlocal = 1 |
||
217 | mov byte [name+position@initlocal],byte@initlocal |
||
218 | else if current@initlocal = 2 |
||
219 | mov word [name+position@initlocal],word@initlocal |
||
220 | else |
||
221 | mov dword [name+position@initlocal],dword@initlocal |
||
222 | end if |
||
223 | position@initlocal = position@initlocal + current@initlocal |
||
224 | end while } |
||
225 | |||
226 | |||
227 | { purge ret,locals,endl |
||
228 | finish@proc |
||
229 | purge finish@proc |
||
230 | restore regs@proc |
||
231 | match all,args@proc \{ restore all \} |
||
232 | restore args@proc |
||
233 | match all,all@vars \{ restore all \} } |
||
234 | |||
235 | |||
236 | { common |
||
237 | locals |
||
238 | forward done@local equ |
||
239 | match varname[count]:vartype, var |
||
240 | \{ match =BYTE, vartype \\{ varname rb count |
||
241 | restore done@local \\} |
||
242 | match =WORD, vartype \\{ varname rw count |
||
243 | restore done@local \\} |
||
244 | match =DWORD, vartype \\{ varname rd count |
||
245 | restore done@local \\} |
||
246 | match =PWORD, vartype \\{ varname rp count |
||
247 | restore done@local \\} |
||
248 | match =QWORD, vartype \\{ varname rq count |
||
249 | restore done@local \\} |
||
250 | match =TBYTE, vartype \\{ varname rt count |
||
251 | restore done@local \\} |
||
252 | match =DQWORD, vartype \\{ label varname dqword |
||
253 | rq count*2 |
||
4039 | heavyiron | 254 | restore done@local \\} |
617 | mikedld | 255 | match =QQWORD, vartype \\{ label varname qqword |
4039 | heavyiron | 256 | rq count*4 |
257 | restore done@local \\} |
||
258 | match =XWORD, vartype \\{ label varname xword |
||
259 | rq count*2 |
||
260 | restore done@local \\} |
||
261 | match =YWORD, vartype \\{ label varname yword |
||
262 | rq count*4 |
||
263 | restore done@local \\} |
||
264 | match , done@local \\{ virtual |
||
617 | mikedld | 265 | varname vartype |
266 | end virtual |
||
267 | rb count*sizeof.\#vartype |
||
268 | restore done@local \\} \} |
||
269 | match :varname:vartype, done@local:var |
||
270 | \{ match =BYTE, vartype \\{ varname db ? |
||
271 | restore done@local \\} |
||
272 | match =WORD, vartype \\{ varname dw ? |
||
273 | restore done@local \\} |
||
274 | match =DWORD, vartype \\{ varname dd ? |
||
275 | restore done@local \\} |
||
276 | match =PWORD, vartype \\{ varname dp ? |
||
277 | restore done@local \\} |
||
278 | match =QWORD, vartype \\{ varname dq ? |
||
279 | restore done@local \\} |
||
280 | match =TBYTE, vartype \\{ varname dt ? |
||
281 | restore done@local \\} |
||
282 | match =DQWORD, vartype \\{ label varname dqword |
||
283 | dq ?,? |
||
284 | restore done@local \\} |
||
285 | match =QQWORD, vartype \\{ label varname qqword |
||
4039 | heavyiron | 286 | dq ?,?,?,? |
287 | restore done@local \\} |
||
288 | match =XWORD, vartype \\{ label varname xword |
||
289 | dq ?,? |
||
290 | restore done@local \\} |
||
291 | match =YWORD, vartype \\{ label varname yword |
||
292 | dq ?,?,?,? |
||
293 | restore done@local \\} |
||
294 | match , done@local \\{ varname vartype |
||
617 | mikedld | 295 | restore done@local \\} \} |
296 | match ,done@local |
||
297 | \{ var |
||
298 | restore done@local \} |
||
299 | common |
||
300 | endl }>> |
||
301 |