|
|
1.1 root 1: ;****************************Public Macro************************************
2: ;
3: ; ComposeInst Inst,p1,p2,p3,p4,p5,p6,p7,p8,p9
4: ;
5: ; This macro simply concatenates all arguments into one string.
6: ;
7: ; History:
8: ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
9: ; Created
10: ;
11: ;****************************************************************************
12:
13: ComposeInst macro Inst,p1,p2,p3,p4,p5,p6,p7,p8,p9
14: &Inst &p1&p2&p3&p4&p5&p6&p7&p8&p9
15: endm
16:
17: ;****************************Public Macro************************************
18: ;
19: ; CountArg cCount,ArgList
20: ;
21: ; This macro count the number of arguments in the ArgList and returns
22: ; the value in cCount.
23: ;
24: ; History:
25: ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
26: ; Created
27: ;
28: ;****************************************************************************
29:
30: CountArg macro cCount,ArgList
31:
32: cCount = 0
33:
34: irp arg,<ArgList>
35: cCount = cCount+1
36: endm
37: endm
38:
39: ;****************************Public Macro************************************
40: ;
41: ; RevPush ArgList,cCount
42: ;
43: ; This macro pushes the arguments in ArgList in the reverse order
44: ; and returns the number of arguments in cCount.
45: ;
46: ; History:
47: ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
48: ; Created
49: ;
50: ;****************************************************************************
51:
52: RevPush macro ArgList,cCount
53: Local index,x
54:
55: CountArg cCount,<ArgList>
56:
57: index = cCount
58: rept cCount
59: x = 0
60: irp arg,<ArgList>
61: x = x+1
62: ife index-x
63: push arg
64: exitm
65: endif
66: endm
67: index = index-1
68: endm
69: endm
70:
71: ;****************************Public Macro************************************
72: ;
73: ; The following sections contain calling-convention related macros for:
74: ;
75: ; PUBLICP Func,N
76: ; to define a public label
77: ;
78: ; EXTRNP Func,N
79: ; to define a external near label
80: ;
81: ; LABELP Func,N
82: ; to label an address as a routine entry point
83: ;
84: ; cProc Func,N,ArgList
85: ; to declare a routine header
86: ;
87: ; ProcName Name,Func,N
88: ; to rename a function Func to Name. Using it in conjunction with
89: ; normal function declaration (with the new name) will solve an error
90: ; caused by a long parameter list routine that exhausts page width.
91: ;
92: ; cRet Func
93: ; to return from Func routines (declared with cProc or ProcName.)
94: ;
95: ; endProc Func
96: ; to declare the end of routine (declared with cProc or ProcName.)
97: ;
98: ; endMod Func
99: ; to declare the end of module with an entry point at Func (declared
100: ; with cProc or ProcName.)
101: ;
102: ; cCall Func,ArgList
103: ; to call to a routine--Func--with the arguments pushed on the stack
104: ;
105: ; ptrCall Func,ArgList
106: ; to call through a pointer with the arguments pushed on the stack
107: ;
108: ; MovAddr dest,Func,n
109: ; to move the address of the routine--Func--into dest.
110: ;
111: ; Note that for the standard calling convention all the function names,
112: ; Func, are automatically converted to Func@N where N is the number of
113: ; bytes in the argument list.
114: ;
115: ; History:
116: ; Thu 15-Aug-1991 16:21:14 -by- Viroon Touranachun [viroont]
117: ; Created
118: ;
119: ;****************************************************************************
120:
121: IFNDEF DOS_PLATFORM
122: IFNDEF STD_CALL
123:
124: ;****************************************************************************
125: ;
126: ; This section is used exclusively for C calling convention.
127: ;
128: ;****************************************************************************
129:
130: PUBLICP macro Func,N
131:
132: public &Func
133: endm
134:
135: EXTRNP macro Func,N
136:
137: extrn &Func:NEAR
138: endm
139:
140: LABELP macro Func,N
141:
142: &Func LABEL NEAR
143: endm
144:
145: ProcName macro Name,Func,N
146:
147: &Name EQU <&Func>
148: endm
149:
150: cProc macro Func,N,ArgList
151:
152: ProcName xxx&Func,Func,N
153:
154: xxx&Func proc &ArgList
155: endm
156:
157: cRet macro Func
158:
159: ret
160: endm
161:
162: endProc macro Func
163:
164: xxx&Func endp
165: endm
166:
167: endMod macro Func
168:
169: end xxx&Func
170:
171: endm
172:
173: ptrCall macro Func,ArgList
174: Local Bytes
175:
176: RevPush <ArgList>,Bytes
177: Bytes = Bytes*4
178:
179: call &Func
180:
181: if Bytes GT 0
182: add esp,Bytes
183: endif
184: endm
185:
186: cCall macro Func,ArgList
187: Local Bytes
188:
189: RevPush <ArgList>,Bytes
190: Bytes = Bytes*4
191:
192: call &Func
193:
194: if Bytes GT 0
195: add esp,Bytes
196: endif
197:
198: endm
199:
200: MovAddr macro dest,addr,n
201:
202: mov dest,offset FLAT:&addr
203: endm
204:
205: ENDIF ; STD_CALL
206:
207: ELSE
208:
209: IFNDEF STD_CALL
210:
211: ;****************************************************************************
212: ;
213: ; This section is used exclusively for Pascal calling convention.
214: ;
215: ;****************************************************************************
216:
217: PUBLICP macro Func,N
218:
219: public &Func
220: endm
221:
222: EXTRNP macro Func,N
223:
224: extrn &Func:NEAR
225: endm
226:
227: LABELP macro Func,N
228:
229: &Func LABEL NEAR
230: endm
231:
232: ProcName macro Name,Func,N
233:
234: &Name EQU <&Func>
235: endm
236:
237: cProc macro Func,N,ArgList
238:
239: ProcName xxx&Func,Func,N
240:
241: xxx&Func proc &ArgList
242: endm
243:
244: cRet macro Func
245:
246: ret
247: endm
248:
249: endProc macro Func
250:
251: xxx&Func endp
252: endm
253:
254: endMod macro Func
255:
256: end xxx&Func
257:
258: endm
259:
260: cCall macro Func,ArgList
261: irp arg,<ArgList>
262: push arg
263: endm
264:
265: call &Func
266: endm
267:
268: MovAddr macro dest,addr,n
269:
270: mov dest,offset FLAT:&addr
271: endm
272:
273: ENDIF : ~STD_CALL
274: ENDIF ; DOS_PLATFORM
275:
276: IFDEF STD_CALL
277: ;****************************************************************************
278: ;
279: ; This section is used exclusively for the standard calling convention.
280: ;
281: ;****************************************************************************
282:
283: PUBLICP macro Func,N
284:
285: ifb <N>
286: public &Func&@0
287: else
288: public &Func&@&N
289: endif
290: endm
291:
292: EXTRNP macro Func,N
293:
294: ifb <N>
295: extrn &Func&@0:NEAR
296: else
297: extrn &Func&@&N:NEAR
298: endif
299: endm
300:
301: LABELP macro Func,N
302:
303: ifb <N>
304: &Func&@0 LABEL NEAR
305: else
306: &Func&@&N LABEL NEAR
307: endif
308: endm
309:
310: ProcName macro Name,Func,N
311:
312: ifb <N>
313: cByte&Func EQU 0
314: &Name EQU <&Func&@0>
315: else
316: cByte&Func EQU N
317: &Name EQU <&Func&@&N>
318: endif
319: endm
320:
321: cProc macro Func,N,ArgList
322:
323: ProcName xxx&Func,Func,N
324:
325: xxx&Func proc &ArgList
326: endm
327:
328: cRet macro Func
329:
330: ret cByte&Func
331:
332: endm
333:
334:
335: endProc macro Func
336:
337: xxx&Func endp
338:
339: endm
340:
341: endMod macro Func
342:
343: end xxx&Func
344:
345: endm
346:
347: ptrCall macro Func,ArgList
348: Local Bytes
349:
350: RevPush <ArgList>,Bytes
351: call &Func
352: endm
353:
354: cCall macro Func,ArgList
355: Local Bytes
356:
357: RevPush <ArgList>,Bytes
358: Bytes = Bytes*4
359:
360: ComposeInst <call>,&Func,<@>,%(Bytes)
361: endm
362:
363: MovAddr macro dest,addr,n
364:
365: ComposeInst <mov >,dest,<,offset FLAT:>,addr,<@>,n
366: endm
367:
368: ENDIF ;STD_CALL
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.