summaryrefslogtreecommitdiff
path: root/v2.0/source/DOSMAC_v211.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v2.0/source/DOSMAC_v211.ASM')
-rw-r--r--v2.0/source/DOSMAC_v211.ASM274
1 files changed, 274 insertions, 0 deletions
diff --git a/v2.0/source/DOSMAC_v211.ASM b/v2.0/source/DOSMAC_v211.ASM
new file mode 100644
index 0000000..3340505
--- /dev/null
+++ b/v2.0/source/DOSMAC_v211.ASM
@@ -0,0 +1,274 @@
1;
2; Macro file for MSDOS.
3;
4
5SUBTTL BREAK a listing into pages and give new subtitles
6PAGE
7BREAK MACRO subtitle
8 SUBTTL subtitle
9 PAGE
10ENDM
11
12BREAK <I_NEED: declare a variable external, if necessary, and allocate a size>
13
14;
15; declare a variable external and allocate a size
16;
17I_NEED MACRO sym,len
18 DATA SEGMENT BYTE PUBLIC 'DATA'
19 IFIDN <len>,<WORD>
20 EXTRN &sym:WORD
21 ELSE
22 IFIDN <len>,<DWORD>
23 EXTRN &sym:DWORD
24 ELSE
25 EXTRN &sym:BYTE
26 ENDIF
27 ENDIF
28 DATA ENDS
29ENDM
30
31;
32; call a procedure that may be external. The call will be short.
33;
34invoke MACRO name
35.xcref
36 IF2
37 IFNDEF name
38 EXTRN name:NEAR
39 ENDIF
40 ENDIF
41.cref
42 CALL name
43ENDM
44
45PAGE
46;
47; jump to a label that may be external. The jump will be near.
48;
49transfer MACRO name
50.xcref
51 IF2
52 IFNDEF name
53 EXTRN name:NEAR
54 ENDIF
55 ENDIF
56.cref
57 JUMP name
58ENDM
59
60;
61; get a short address in a word
62;
63short_addr MACRO name
64 IFDIF <name>,<?>
65.xcref
66 IF2
67 IFNDEF name
68 EXTRN name:NEAR
69 ENDIF
70 ENDIF
71.cref
72 DW OFFSET DOSGROUP:name
73 ELSE
74 DW ?
75 ENDIF
76ENDM
77
78;
79; get a long address in a dword
80;
81long_addr MACRO name
82.xcref
83 IF2
84 IFNDEF name
85 EXTRN name:NEAR
86 ENDIF
87.cref
88 DD name
89ENDM
90
91;
92; declare a PROC near or far but PUBLIC nonetheless
93;
94procedure MACRO name,distance
95 PUBLIC name
96name PROC distance
97ENDM
98
99PAGE
100;
101; define a data item to be public and of an appropriate size/type
102;
103I_AM MACRO name,size
104 PUBLIC name
105
106 IFIDN <size>,<WORD>
107name DW ?
108 ELSE
109 IFIDN <size>,<DWORD>
110name DD ?
111 ELSE
112 IFIDN <size>,<BYTE>
113name DB ?
114 ELSE
115name DB size DUP (?)
116 ENDIF
117 ENDIF
118 ENDIF
119ENDM
120
121PAGE
122;
123; call the macro chain
124;
125do_ext macro
126endm
127
128PAGE
129
130;
131; define an entry in a procedure
132;
133entry macro name
134 PUBLIC name
135name:
136endm
137
138BREAK <ERROR - print a message and then jump to a label>
139
140error macro code
141 local a
142.xcref
143 MOV AL,code
144 transfer SYS_RET_ERR
145.cref
146ENDM
147
148BREAK <JUMP - real jump that links up shortwise>
149;
150; given a label <lbl> either 2 byte jump to another label <lbl>_J
151; if it is near enough or 3 byte jump to <lbl>
152;
153
154jump macro lbl
155 local a
156.xcref
157 a:
158 ifndef lbl&_J ;; is this the first invocation
159 JMP lbl
160 ELSE
161 IF lbl&_J GE $
162 JMP lbl
163 ELSE
164 IF ($-lbl&_J) GT 126 ;; is the jump too far away?
165 JMP lbl
166 ELSE ;; do the short one...
167 JMP lbl&_J
168 ENDIF
169 ENDIF
170 ENDIF
171 lbl&_j = a
172.cref
173endm
174
175BREAK <RETURN - return from a function>
176
177return macro
178 local a
179.xcref
180a:
181 RET
182ret_l = a
183.cref
184endm
185
186BREAK <CONDRET - conditional return>
187
188makelab macro l,cc,ncc
189 local a
190 j&ncc a ;; j<NCC> a:
191 return ;; return
192 a: ;; a:
193 ret_&cc = ret_l ;; define ret_<CC> to be ret_l
194endm
195
196condret macro cc,ncc
197 local a,b
198 ifdef ret_l ;; if ret_l is defined
199 if (($ - ret_l) le 126) and ($ gt ret_l)
200 ;; if ret_l is near enough then
201 a: j&cc ret_l ;; a: j<CC> to ret_l
202 ret_&cc = a ;; define ret_<CC> to be a:
203 else
204 makelab a,cc,ncc
205 endif
206 else
207 ifdef ret_&cc ;; if ret_<CC> defined
208 if (($ - ret_&cc) le 126) and ($ gt ret_&cc)
209 ;; if ret_<CC> is near enough
210 a: j&cc ret_&cc ;; a: j<CC> to ret_<CC>
211 ret_&cc = a ;; define ret_<CC> to be a:
212 else
213 makelab a,cc,ncc
214 endif
215 else
216 makelab a,cc,ncc
217 endif
218 endif
219endm
220;condret macro cc,ncc
221; local a,b
222; ifdef ret_l ; if ret_l is defined
223; if (($ - ret_l) le 126) and ($ gt ret_l)
224; ; if ret_l is near enough then
225; a: j&cc ret_l ; a: j<CC> to ret_l
226; ret_&cc = a ; define ret_<CC> to be a:
227; exitm
228; endif
229; endif
230; ifdef ret_&cc ; if ret_<CC> defined
231; if (($ - ret_&cc) le 126) and ($ gt ret_&cc)
232; ; if ret_<CC> is near enough
233; a: j&cc ret_&cc ; a: j<CC> to ret_<CC>
234; ret_&cc = a ; define ret_<CC> to be a:
235; exitm
236; endif
237; endif
238; j&ncc a ; j<NCC> a:
239; return ; return
240; a: ; a:
241; ret_&cc = ret_l ; define ret_<CC> to be ret_l
242;endm
243;
244BREAK <RETZ - return if zero, links up shortwise if necessary>
245
246retz macro
247 condret z,nz
248endm
249
250BREAK <RETNZ - return if not zero, links up shortwise if necessary>
251
252retnz macro
253 condret nz,z
254endm
255
256BREAK <RETC - return if carry set, links up shortwise if necessary>
257
258retc macro
259 condret c,nc
260endm
261
262BREAK <RETNC - return if not carry, links up shortwise if necessary>
263
264retnc macro
265 condret nc,c
266endm
267
268BREAK <CONTEXT - set the DOS context to a particular register>
269
270context macro r
271 PUSH SS
272 POP r
273 ASSUME r:DOSGROUP
274endm