1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
;++
;
;Copyright (c) 1991 Microsoft Corporation
;
;Module Name:
;
; debugmac.inc
;
;Abstract:
;
; Contains debugging macros:
;
; DbgBreakPoint
; DbgUnsupported
; DbgDEBUG
; DbgPrint
; DbgPrintTty
; DbgPrintString
; DbgPrintHexDword
; DbgPrintHexWord
; DbgPrintHexByte
; DbgPrintNearPointer
; DbgPrintFarPointer
;
;Author:
;
; Richard L Firth (rfirth) 13-Sep-1991
;
;Environment:
;
; DOS application mode only
;
;[Notes:]
;
; optional-notes
;
;Revision History:
;
; 13-Sep-1991 rfirth
; Created
;
;--
;*** DbgBreakPoint
;*
;* Same as NT routine of same name. No-op in non-DEBUG version
;*
;* ENTRY
;*
;* EXIT
;*
;* RETURNS
;*
;* ASSUMES
;*
;***
DbgBreakPoint macro
if DEBUG
int 3
endif
endm
;*** DbgUnsupported
;*
;* Causes the 32-bit support code to display a message about an unsupported
;* service code, and dumps the 16-bit registers. Used to discover when an
;* unsupported int 2f/11 call or int 21/5f call is being made
;*
;* ENTRY
;*
;* EXIT
;*
;* RETURNS
;*
;* ASSUMES
;*
;***
DbgUnsupported macro
if DEBUG
SVC -1
endif
endm
;*** DbgDEBUG
;*
;* Prints the string "DEBUG: " to console using Bios Int 10h/ah=0eh
;*
;* ENTRY nothing
;*
;* EXIT nothing
;*
;* USES ax
;*
;* ASSUMES 286+
;*
;***
DbgDEBUG macro
mov ax,(14 shl 8) + 'D'
int 10h
mov al,'E'
int 10h
mov al,'B'
int 10h
mov al,'U'
int 10h
mov al,'G'
int 10h
mov al,':'
int 10h
mov al,' '
int 10h
endm
;*** DbgCrLf
;*
;* Prints CR,LF to console using Bios Int 10h/ah=0eh
;*
;* ENTRY nothing
;*
;* EXIT nothing
;*
;* USES nothing
;*
;* ASSUMES 286+
;*
;***
DbgCrLf macro
push ax
mov ax,(14 shl 8) + 13
int 10h
mov al,10
int 10h
pop ax
endm
;*** DbgPrint
;*
;* Prints an ASCIZ string to console using Bios Int 10h
;*
;* ENTRY string - address of ASCIZ string to print
;*
;* EXIT nothing
;*
;* USES nothing
;*
;* ASSUMES 286+
;*
;***
DbgPrint macro string
if DEBUG ;; no macro if not debug version
pushf ;; save regs used by DbgPrintTty
push ax
push bx
push si
push ds
mov ax,seg string
mov ds,ax
mov si,offset string;; ds:si = address of string
DbgPrintTty ;; display it on console
pop ds
pop si
pop bx
pop ax
popf
endif
endm
;*** DbgPrintTty
;*
;* Prints an ASCIZ string in ds:si to console using Bios Int 10h
;*
;* ENTRY page - if present defines which Bios video page to use
;* Defaults to 0
;* ds:si - address of ASCIZ string to print
;*
;* EXIT nothing
;*
;* USES al, bh, si, flags
;*
;* ASSUMES 286+
;*
;***
DbgPrintTty macro page
local l1,l2
if DEBUG ;; no macro if not debug version
mov ah,14 ;; Bios Int write character as TTY function
ifb <page>
sub bh,bh
else
mov bh,page
endif
cld ;; autoincrement lodsb
l1: lodsb ;; al := next character; si := next character addr
or al,al ;; eof string?
jz l2 ;; yes
int 10h ;; display it to console
jmp short l1 ;; go round again
l2:
endif
endm
;*** DbgPrintString
;*
;* Prints a string to console using Bios Int 10h. Note that this macro
;* does not do printf style substitutions. The string "DEBUG: " will be
;* displayed if the banner parm is not blank
;*
;* ENTRY string - character string. Needn't be zero-terminated
;* banner - the "DEBUG: " banner will be printed if not blank
;*
;* EXIT nothing
;*
;* USES nothing
;*
;* ASSUMES 286+
;*
;***
DbgPrintString macro string, banner
local s1
local l1
if DEBUG ;; no macro if not debug version
jmp short l1
s1 db &string,0
l1: pushf ;; don't destroy direction flag
pusha ;; save gp regs
ifb <banner>
DbgDEBUG ;; Display "DEBUG: "
endif
push ds ;; save user's data seg
push cs
pop ds ;; ds == cs
mov si,offset cs:s1 ;; si := string offset
DbgPrintTty ;; display ds:si to console
pop ds ;; restore user's data seg
popa ;; restore gp regs
popf ;; restore direction flag+
endif
endm
;*** DbgPrintHexDword
;*
;* Prints a dword to console in hex notation using Bios Int 10h
;*
;* ENTRY dword - dword to print
;*
;* EXIT nothing
;*
;* USES nothing
;*
;* ASSUMES 286+
;*
;***
DbgPrintHexDword macro dword
if DEBUG ;; no macro if not debug version
DbgPrint <"DbgPrintHexDword not implemented yet",13,10>
endif
endm
;*** DbgPrintHexWord
;*
;* Prints a word to console in hex notation using Bios Int 10h
;*
;* ENTRY word - to print. Can be memory or register
;*
;* EXIT nothing
;*
;* USES nothing
;*
;* ASSUMES 286+
;*
;***
DbgPrintHexWord macro word
local l1, l2
if DEBUG ;; no macro if not debug version
pushf ;; don't use any registers
push ax
push cx
push dx
ifdifi <word>,<ax>
mov ax,word
endif
mov cx,4
l1: rol ax,4
mov dx,ax
and al,0fh
cmp al,9
jle l2
add al,'a'-('9'+1)
l2: add al,'0'
mov ah,14
int 10h
mov ax,dx
loop l1
pop dx
pop cx
pop ax
popf
endif
endm
;*** DbgPrintHexByte
;*
;* Prints a string to console using Bios Int 10h. Note that this macro
;* does not do printf style substitutions
;*
;* ENTRY string - character string. Needn't be zero-terminated
;*
;* EXIT
;*
;* USES nothing
;*
;* ASSUMES 286+
;*
;***
DbgPrintHexByte macro byte
if DEBUG ;; no macro if not debug version
DbgPrint <"DbgPrintHexByte not implemented yet",13,10>
endif
endm
DbgPrintNearPointer macro nearptr
endm
DbgPrintFarPointer macro farptr
endm
|